CJCoding With Joseph
← Back to Question List
C++ Code Walkthrough #32

Factorial Recursion

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