1*2*3*4*..*N- ko’paytma qiymatini hisoblovchi funksiya yarating.
function fakt(n:integer):integer;
var p,i:INTEGER;
begin p:=1;
FOR i:=1 To n DO
P:=P*i;
fakt:=p;
end;
10-masala.
Yaratilgan fak-funksiyasi yordamida quyidagi yig’indini hisoblash dasturini tuzing:
1+1*2+1*2*3+1*2*3*4+1*2*3*4*5
(1!+2!+3!+4!+5!=?)
var k,s:integer;
function fakt(n:integer):integer;
var p,i:INTEGER;
begin p:=1;
FOR i:=1 To n DO
P:=P*i;
fakt:=p;
end;
begin
for k:=1 to 5 do
s:=s+fakt(k);
writeln(S);
readln;
END.
Do'stlaringiz bilan baham: |