We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 40a9a6e commit a849dc6Copy full SHA for a849dc6
1 file changed
factorial.py
@@ -1,9 +1,14 @@
1
+#finding factorial of a number using recursion by user input
2
+n=int(input("Enter a number: "))
3
def fact(n):
4
if (n==0 or n==1):
5
return 1
6
else:
7
return fact(n-1)*n
-
8
9
-print(fact(6))
+print(f"Factorial of {n} is {fact(n)}")
+# Finding factorial of a number using loop by user input
10
+n=int(input("Enter a number to find its factorial: "))
11
+factorial = 1
12
+for i in range(1, n+1):
13
+ factorial *= i
14
+print(f"The factorial of {n} is: {factorial}")
0 commit comments