Last active
October 11, 2023 08:18
-
-
Save juanfal/aa19aa5fd6093f1905fd to your computer and use it in GitHub Desktop.
Factorial using for loop
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
// factorial.for.cpp | |
// juanfc 2023-10-11 | |
// plain for loop to compute a factorial | |
// https://gist.github.com/aa19aa5fd6093f1905fd | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int n; | |
cout << "n?: "; | |
// cin >> n; | |
n = 16; | |
long long unsigned 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