All problems
MediumFunctions
Recursive factorial
Write `fact(n)` recursively. n! = n * (n-1)!, with fact(0) = 1.
- #recursion
- #math
Sample input
5
Sample output
120
recursive-factorial.py
Output
Press "Run code" to execute.
Write `fact(n)` recursively. n! = n * (n-1)!, with fact(0) = 1.
5
120
Press "Run code" to execute.
Admissions open · free to apply
Attended a masterclass or have a friend's referral code? You get ₹15,000 off. Fill this and our team takes it from here — pay by cash or online.
Free to apply · masterclass attendees & referrals get ₹15,000 off · our team guides you next.
By submitting, you agree to our Privacy Policy and to be contacted about your enquiry.