Skip to content

Instantly share code, notes, and snippets.

@juanfal
Created October 17, 2012 12:12
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 juanfal/3905222 to your computer and use it in GitHub Desktop.
Save juanfal/3905222 to your computer and use it in GitHub Desktop.
How long can an integer be: for loop to compute a factorial
// 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