Click
New Example
to start working through an example. Click on instructions in the steps of the algorithm to see the values of the variables in each step. First click on step 1. and then on the following steps in the order of execution.
New Example
Restart Example
Algorithm.
Sum of the natural numbers up to
n
.
Input:
A natural number
n
Output:
The sum of the natural numbers up to
n
let
i
:= 0
let
s
:= 0
repeat
let
i
:=
i
+ 1
let
s
:=
s+i
until
i
=
n
return
s