+ 1

I need help for my coding exercice

In this programm i has to calculate n! Where n is a variable of type int. Can someone help me please? n=... Factorial=... For i in range(...): ....... Print(...)

15th Oct 2019, 7:56 PM
_C1B3R_
_C1B3R_ - avatar
3 Respuestas
+ 3
iterative: n = int(input("n: \n")) fac = 1 for i in range(2, n): fac *= i print(str(n) + "! = " + str(fac)) recusive: def fac(n): if n == 0: return 1 else: return n * fac(n-1) n = int(input("n: \n")) print(str(n) + "! = " + str(fac(n)))
15th Oct 2019, 8:04 PM
Anton Böhler
Anton Böhler - avatar
0
Thank you so much !
16th Oct 2019, 5:50 AM
_C1B3R_
_C1B3R_ - avatar