Precomputation

 // Online C++ compiler to run C++ program online

#include <iostream>

using namespace std;

const int m=1e9+7;

const int n=1e5+10;

long long fact[n];

int main() {

    fact[0]=fact[1]=1;

    for(int i=2;i<n;i++){

        fact[i]=fact[i-1]*i;

    }

    int num;

    cin>>num;

    cout<<fact[num];

    

    


    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings