Challenge: Factorial
Let’s create a program that calculates factorials using recusion.
Problem
For a given value find , where = . Solve this problem using recursion.
Input
A positive integer.
Output
A factorial.
Sample input
5
Sample output
Answer: 120 // 5*4*3*2*1
Coding exercise
Try to solve this yourself first. If you get stuck or need help, you can always press the “Show Solution” button to see how your problem can be solved. We’ll look at the solution in the next lesson.
Good luck!
Access this course and 1400+ top-rated courses and projects.