fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. unsigned long long factorial(int n) {
  5. unsigned long long result = 1;
  6. for (int i = 2; i <= n; i++) {
  7. result *= i;
  8. }
  9. return result;
  10. }
  11.  
  12. int main() {
  13. int n;
  14. cin >> n;
  15. cout << factorial(n) << endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 5320KB
stdin
3

stdout
6