ncr function

 #include <iostream>

using namespace std;


int fact(int n){

    int mul=1;

    int i=1;

    while( i<=n){

        mul=mul*i;

        i++;

    }

    return mul;

}

int ncr(int n, int r){

    return (fact(n)/(fact(r)*fact(n-r)));

}


int main() {

    // Write C++ code here

    int n,r;

    cin>>n>>r;

    cout<<ncr(n,r);

    


    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings