Playground
#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 = 4; int f = factorial(n); //f = 24 cout << f << endl; //pechati '24' (1*2*3*4) return 0; }
Input data
Program output
no input
Execute
Language: ????????? | Memory: ???? KB | Time: ??? ms
Nothing has been executed, yet!