👤

Program care calculeaza expresia matematica:

S =1 ! +2 ! + ... n !
! - factorial

(IN PASCAL)

Va rog Am nevoie urgent dau coronita!


Răspuns :

var

 y, n, i: longint;

 

function fact(x: longint): longint;

begin

 if x = 1 then fact := 1

 else fact := x * fact(x - 1);

end;

 

begin

 writeln('Numarul N:');

 readln(n);

 if (n > 1) then

 begin

   y := 0;

   for i := 1 to n do

   begin

     y := y + fact(i);

   end;

   writeln('y = ', y);

 end

 else writeln('Incorect');

end.