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