#include #include using namespace std; /** Computes the factorial of the nonnegative integer n. * @pre n must be greater than or equal to 0. * @post None. * @return The factorial of n; n is unchanged. */ int fact(int n) { if (n == 0) return 1; else return n * fact(n-1); } int main() { int N, result; cout << "Enter a non-negative integer: "; cin >> N; if(N < 0){ cout << N << " is a negative integer\n"; exit(0); } result = fact(N); cout << "Factorial of " << N << " is " << result << endl; return 0; }