Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 6, 2020 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/dc578eee1515e3ddfa120dcf3a9bf447 to your computer and use it in GitHub Desktop.
Save amankharwal/dc578eee1515e3ddfa120dcf3a9bf447 to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
int fact(int n){
int factorial = 1;
for (int i = 2; i <= n; i++){
factorial *= i;
}
return factorial;
}
int main(){
int n;
cin>>n;
int ans = fact(n);
cout<<ans<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment