// Use loop to comput - // Sum(N) = N + (N-1) + ... 2 + 1 // Add a loop, 0 to quit #include using namespace std; // loop function for sum int f(int n) { int s=0; for(int i=1; i<=n; i++) s += i; // 1 + 2 + .. n return s; } int main() { int N; cout << "Max: " << INT_MAX << "\n\n"; cout << "input N for computing N! - "; cin >> N; while( N != 0 ) { cout << "Sum(N) = " << f(N) << "\n\n"; cout << "input N for computing Sum(N) (0 to quit): "; cin >> N; } return 0; }