from time import time # Fonction factorielle itérative : def factorielle_1(n): fact = 1 i = 2 while i <= n: fact = fact * i i = i + 1 return fact # Fonction factorielle récurcive : def factorielle_2(n): if n<=1: return 1 else: return n*factorielle_2(n-1) nombre=int(input("Entrez un entier supérieur à 1 :")) debut=time() print(factorielle_1(nombre)) fin=time() print("Temps passé pour l'algorithme itératif : %s secondes" % (fin-debut)) debut=time() print(factorielle_2(nombre)) fin=time() print("Temps passé pour l'algorithme récurcif : %s secondes" % (fin-debut))