fork download
  1. #include <iostream>
  2.  
  3. constexpr int factorial(int n) // Everything here is known at compile time
  4. {
  5. return n <= 1 ? 1 : (n * factorial(n - 1));
  6. }
  7.  
  8. int main(void)
  9. {
  10. int i;
  11. std::cin >> i;
  12. const int f = factorial(i); // I really can't guess this at compile time..
  13. std::cout << f << std::endl;
  14. return 0;
  15. }
Success #stdin #stdout 0s 3300KB
stdin
4
stdout
24