Skip to content

Commit 09ba744

Browse files
Merge pull request #34 from codewithdhruba01/codewithdhruba01-patch-1
Add recursive factorial function in question.py
2 parents 522592a + 20198fa commit 09ba744

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

12_Recursion/question.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Factorial of a number nikalne ke liye recursive function likho.
2+
3+
def factorial(n):
4+
if n == 0 or n == 1:
5+
return 1
6+
return n * factorial(n - 1)
7+
8+
print(factorial(5)) # Output: 120
9+
10+
## Har step me number ko uske previous number ke factorial se multiply karte hain.

0 commit comments

Comments
 (0)