formations/algorithmique/cours/code/factorielle.py

13 lines
230 B
Python
Raw Normal View History

2017-04-06 16:57:22 +02:00
def factorielle(n):
if (n > 1):
r = n*factorielle(n-1)
else:
r = 1
return r
def print_fact(n):
print "factorielle {} = {}\n".format(5, factorielle(5))
if __name__ == '__main__':
print_fact(5)