Jump to content

Sum of first n cubes: Difference between revisions

(→‎{{header|JavaScript}}: Replaced a more general maximum with Math.max and a spread operator.)
(insert →‎Pascal)
Line 1,443:
=={{header|PARI/GP}}==
<lang parigp>c=0;for(n=0,49,c=c+n^3;print(c))</lang>
 
=={{header|Pascal}}==
<lang pascal>program sumOfFirstNCubes(output);
const
N = 49;
var
i: integer;
sum: integer;
begin
sum := 0;
for i := 0 to N do
begin
sum := sum + sqr(i) * i;
{ In Extended Pascal you could also write:
sum := sum + i pow 3; }
writeLn(sum)
end
end.</lang>
 
=={{header|Perl}}==
149

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.