<?php
$x = 10;
// Sum of numbers from 1 to n
$sum = 0;
for ($i = 1; $i <= $x; $i++) {
$sum += $i;
}
echo "SUM of numbers from 1 to $x: $sum\n";
// easy way to calculate SUM of numbers to n
$sum = $from1To * ($x+1) / 2;
echo "SUM of numbers from 1 to $x: $sum\n";