Explore Connect Documentation
Snippets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;
int factorial(int n) {
  if (n == 1) {
    return 1;
  }
  
  return n * factorial(n - 1);
}
int main() {
  cout << factorial(3) << endl; // prints 6
  
  return 0;
}
Press desired key combination and then press ENTER.