Multiply two numbers

 

#include <bits/stdc++.h>
using namespace std ;
int multiply(int m,int n){
    //base case
    if(n==0return 0;

    //Recursive case
    int smallAns = multiply(m,n-1) ;

    //Calculation
    return smallAns + m ;

}


int main (){
    cout << multiply(5,3<< '\n';
    return 0 ;
}

Comments

Popular posts from this blog

CodeChef::CSUB

How Recursion Works?

CodeChef::TREE2