Вычислите для первых n элементов: a) 1+3+5+7+ и 1*3*5*7*; b)2+4+6+8+ и 2*4*6*8*; c)3+6+9+12+ и 3*6*9*12*; d)4+8+12+ и 4*8*12*16*; например: при n=3 имеем 1+3+5=9; 1*3*5=15. надо решить с оператором for, для pascal 7.0.
procedure L(n,first,step:integer); var i,s,current:integer; p:double; begin p:=1; s:=0; current:=first; for i:=1 to n do begin s:=s+current; p:=p*current; Write(current,','); current:=current+step end; Writeln(' : S=',s,', П=',p) end;
var n:integer; begin ClrScr; Write('n='); Read(n); L(n,1,2); L(n,2,2); L(n,3,3); L(n,4,4); ReadKey end.
uses Crt;
procedure L(n,first,step:integer);
var
i,s,current:integer;
p:double;
begin
p:=1;
s:=0;
current:=first;
for i:=1 to n do begin
s:=s+current;
p:=p*current;
Write(current,',');
current:=current+step
end;
Writeln(' : S=',s,', П=',p)
end;
var
n:integer;
begin
ClrScr;
Write('n=');
Read(n);
L(n,1,2);
L(n,2,2);
L(n,3,3);
L(n,4,4);
ReadKey
end.