Created
October 17, 2012 12:12
-
-
Save juanfal/3905222 to your computer and use it in GitHub Desktop.
How long can an integer be: for loop to compute a factorial
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
// 03.fact.cpp | |
// juanfc 2003-11-11 | |
// How long can an integer be: | |
// for loop to compute a factorial | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
cout << "n?: "; | |
unsigned int n; | |
cin >> n; | |
unsigned long long int f = 1; | |
for (int i = 2; i < n; ++i) { | |
f *= i; | |
} | |
cout << n << "!: " << f << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment