Multiply two numbers
#include <bits/stdc++.h>
using namespace std ;
int multiply(int m,int n){
//base case
if(n==0) return 0;
//Recursive case
int smallAns = multiply(m,n-1) ;
//Calculation
return smallAns + m ;
}
int main (){
cout << multiply(5,3) << '\n';
return 0 ;
}
Comments
Post a Comment