' field below. // Please check man page for isset function. $submitted = isset($_GET['submitted']); if ($submitted) { echo "

The result is:

\n

"; $n = $_GET['n_value']; $i = 1; $s = ($n == 0) ? 0 : 1; $s_string = ($n == 0) ? '0 ' : '1 '; while ($i < $n) { $i++; $s = $s + $i; $s_string = $s_string."+ $i "; } echo "S($n) = $s_string"."= $s"; echo "

\n

".'recompute.

'; echo "\n

".'Other curious facts on 1+2+3+4+....

'; } else { echo '

This calculator computes the Little Gauss sum, S(n) = 1 + 2 + 3 + ... + (n-1) + n:

n:
'; } ?>