Recursion matrix: no of paths

 #include<iostream>

using namespace std;


int path(int m, int n);


int main()

{

    int a,b;


    

    cin >>a>>b;


   cout<<path(a,b);


    return 0;

}


int path(int m,int n)

{

    if(m == 1 || n==1)

        return 1;

    return path(m,n-1)+path(m-1,n);

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings