What does fun2() do in general?
int fun(int x, int y)
int
fun(
x,
y)
{
if (y == 0) return 0;
if
(y == 0)
return
0;
return (x + fun(x, y-1));
(x + fun(x, y-1));
}
int fun2(int a, int b)
fun2(
a,
b)
if (b == 0) return 1;
(b == 0)
1;
return fun(a, fun2(a, b-1));
fun(a, fun2(a, b-1));
power function i.e ab.
Note that, fun(a,b) returns a*b as output
fun2(a,b) = fun (a,fun2(a,b-1)) = a * fun2(a,b-1) --------------> (1)
= a* fun(a,fun2(a,b-2))
= a * a * fun2(a,b-2) --------------> (2)
from 1 and 2, you can generalize, it as ab.
64.3k questions
77.9k answers
244k comments
80.0k users