[ create a new paste ] login | about

Link: http://codepad.org/VDB2qYSD    [ raw code | output | fork ]

C++, pasted on Oct 31:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

using namespace std;
int factorial(int n){
    int res =1 ;
    for(int i=2; i<=n;i++)
    res*=i;
    return res;
}
int main() {
    int n;
    cin >> n;
    int res = factorial(n);
    cout << res << endl;
    return 0;


Output:
1
2
3
In function 'int main()':
Line 15: error: expected `}' at end of input
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: