efrei/algorithmique/recursivite/factorielle.py

19 lines
290 B
Python
Raw Normal View History

2021-09-17 13:40:21 +02:00
#!/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()