Answer:
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter number: ";
cin >> n;
int fact = 1;
for(int i=2; i<=n; i++) {
fact *= i;
}
cout << n << "! = " << fact << endl;
}
Explanation:
Another cool way to do this is to write a recursive function. But here specifically a for loop was asked.