Académique Documents
Professionnel Documents
Culture Documents
Fonction Factoriel PDF
Fonction Factoriel PDF
On
suppose que 0! = 1
Analyse de la fonction
fact
i
Objet
TYPE
entier
entier
Algorithme
0) DEFFN factorielle(n : entire) : entier
1) fact 1
2) si si (n 0) alors
Pour i de 1 n rpter
fact = fact . i
FinPour
FinSi
3) factorielle = fact
4) Fin factorielle
Traduction en Pascal
FUNCTION factorielle(n : INTEGER) : INTEGER.
VAR
i : INTEGER;
fact : INTEGER;
BEGIN
fact := 1;
IF (n<>0) THEN
FOR i:=1 TO n DO
fact:= fact *i;
factorielle := fact;
END;
ROLE
va contenir factorielle n
compteur