Add factorielle

This commit is contained in:
flyingscorpio@arch-desktop 2021-09-17 13:40:21 +02:00
parent 13970cb831
commit f2317e69ca
2 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,13 @@
Algorithme : Calcule la factorielle d'un entier N positif
Début
Fonction Factorielle(N : int)
Si N = 1
Retourner(1)
Sinon
Retourner(N * Factorielle(N - 1))
FinSi
FinFonction
Fin

View file

@ -0,0 +1,18 @@
#!/usr/bin/env python
"""Algorithme : Calcule la factorielle d'un entier N positif"""
def main() -> None:
print(Factorielle(5))
def Factorielle(N : int) -> int:
if N == 1:
return 1
else:
return N * Factorielle(N - 1)
if __name__ == "__main__":
main()