+ 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(...)
3 odpowiedzi
+ 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)))
0
Thank you so much !
0
If you want to enhance your coding skills then you can go for Data Analytics with Python. With the help of this course you can enhance your knowledge in ML, Data Analytics,Data Science etc. For more check this link: https://www.cetpainfotech.com/technology/data-analytics-using-python-training