Skip to content

Instantly share code, notes, and snippets.

@isdampe
Created August 28, 2018 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isdampe/a937e6d2eb9c7f2be9196143f7ac19db to your computer and use it in GitHub Desktop.
Save isdampe/a937e6d2eb9c7f2be9196143f7ac19db to your computer and use it in GitHub Desktop.
#include <iostream>
using std::cout;
int factorial(int n)
{
if (n > 1)
return n * factorial(n -1);
return n;
}
int main()
{
cout << "The factorial of 5 is " << factorial(5) << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment