fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int f(int n) {
  5. if (n > 0) {
  6. return n * f(n - 1);
  7. } else {
  8. return 1;
  9. }
  10. }
  11.  
  12. int main() {
  13. cout << "10! = " <<f(10) << endl;
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
10! = 3628800