2 réponses
salut daniouta, voici le programme pascal qui calcule le factoriel d'un nombre entier.
program factor;
uses crt;
var y,f,i,z:integer;
function fact(x:integer):longint;
begin
if x=0 then
f:=1
else
f:=1;
for i:=1 to x do
f:=f*i;
fact:=f;
end;
begin clrscr;textcolor(10);
gotoxy(07,05);write('donner un nombre entier : ');
readln(f);z:=f;
y:=fact(f);
gotoxy(07,07);write('le factoriel de ',z,' est = ', y);
readln;
end.
program factor;
uses crt;
var y,f,i,z:integer;
function fact(x:integer):longint;
begin
if x=0 then
f:=1
else
f:=1;
for i:=1 to x do
f:=f*i;
fact:=f;
end;
begin clrscr;textcolor(10);
gotoxy(07,05);write('donner un nombre entier : ');
readln(f);z:=f;
y:=fact(f);
gotoxy(07,07);write('le factoriel de ',z,' est = ', y);
readln;
end.