CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Factorial Recursion

C++ code walkthrough · Question 32
mediumRecursion

Code

Read carefully. What does this print?
1#include <iostream>
2using namespace std;
3int fact(int n) {
4 if (n <= 1) return 1;
5 return n * fact(n - 1);
6}
7int main() {
8 cout << fact(5) << endl;
9 return 0;
10}

Your answer