Structura in Pascal folosind repetitiva cu test initial:
-are forma:
Citeste n;
S<--- 0;
k<--- 1;
Cat timp k <= n+1
inceput
S<--- S + k * (2 * k +1)
k<--- k + 1
sfarsit;
Scrie S;
Sfarsit.
-in pseudocod:
Program sum;
var S, n, x, k : integer;
begin
Read (n);
Read (x);
S:= 0;
k:= 1;
While k<=n do
begin
S:= S+x;
k:= k+1;
Read (x);
end;
Write (S);
end.