Last active
August 29, 2015 14:22
-
-
Save GregGallant/006af087cfc6382fe7d1 to your computer and use it in GitHub Desktop.
I love factorials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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