Skip to content

Instantly share code, notes, and snippets.

@GregGallant
Last active August 29, 2015 14:22
Show Gist options
  • Save GregGallant/006af087cfc6382fe7d1 to your computer and use it in GitHub Desktop.
Save GregGallant/006af087cfc6382fe7d1 to your computer and use it in GitHub Desktop.
I love factorials
// A Factorial in C++
#include <iostream>
using namespace std;
long factorial (long fac)
{
if (fac > 1)
return (fac * factorial (fac-1));
else
return 1;
}
int main ()
{
long number = 9;
cout << number << "! = " << factorial (number);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment