I can multiply two numbers without using multiplication operator in c. I know that in recursion we call function inside function. I don't understand the recursion method for multiplying two numbers.
https://www.geeksforgeeks.org/multi...iply-division-bitwise-operators-and-no-loops/
can someone explain math for multiplying two numbers using recursion ?
C:
#include<stdio.h>
int main()
{
int x = 2;
int y = 4;
int mul = 0;
// x = 0 + 2 = 2
// x = 2 + 2 = 4
// x = 4 + 2 = 6
// x = 6 + 2 = 8
for (int i = 0; i < y; i++)
{
mul = (mul + x);
}
printf("%d", mul);
return 0;
}
can someone explain math for multiplying two numbers using recursion ?