Var n,a,b:integer;
function sum(x,y:integer):integer;
var s,i:integer;
begin
s:=0;
for i:=x to y do s:=s+i*i;
sum:=s;
end;
begin
write('n = ');
readln(n);
writeln(n,'^2 + ',n+1,'^2 + ... + ',n+n,'^2 = ',sum(n,n+n));
write('a, b = ');
readln(a,b);
writeln(a,'^2 + ',a+1,'^2 + ... + ',b,'^2 = ',sum(a,b));
end.
Пример:
n = 5
5^2 + 6^2 + ... + 10^2 = 355
a, b = 5 10
5^2 + 6^2 + ... + 10^2 = 355