int factorial(int num) { int result = 1; for (int i = 1; i <= num; ++i) { result = result * i; } return result; } int main(void) { int num = 5; int result = 0; //factorial for loop result = factorial(num); //print cout << "factorial " << num << "! : " << result << endl; return 0; }