function factorial

 #include <iostream>

using namespace std;


int factorial(int n){

    if(n<=0){

        return 1;

    }

    else{

        return (n)*factorial(n-1);

    }

}


int main() {

    // Write C++ code here

    int n1,n2;

    cout<<"enter 1 no : ";

    cin>>n1;

    cout<<"enter 2 no : ";

    cin>>n2;

    factorial(n1);

    factorial(n2);

    cout<<factorial(n1)<<endl;

    cout<<factorial(n2)<<endl;

   


    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings