fork download
  1. #include <iostream>
  2.  
  3. uint64_t f(uint64_t p, int c) {
  4. if (c == 0)
  5. return p;
  6. return f(p * c, c - 1);
  7. }
  8.  
  9. int main() {
  10. for (int i = 1; i < 20; i++) {
  11. std::cout << f(1, i) << std::endl;
  12. }
  13. return 0;
  14. }
  15. /* end */
  16.  
Success #stdin #stdout 0s 4212KB
stdin
Standard input is empty
stdout
1
2
6
24
120
720
5040
40320
362880
3628800
39916800
479001600
6227020800
87178291200
1307674368000
20922789888000
355687428096000
6402373705728000
121645100408832000