What does fun2() do in general?
#include <iostream> int fun(int x, int y) { if (y == 0) return 0; return (x + fun(x, y-1)); } int fun2(int a, int b) { if (b == 0) return 1; return fun(a, fun2(a, b-1)); }
int fun(int x, int y) { if (y == 0) return 0; return (x + fun(x, y-1)); } int fun2(int a, int b) { if (b == 0) return 1; return fun(a, fun2(a, b-1)); }
public class Main { public static int fun(int x, int y) { if (y == 0) return 0; return (x + fun(x, y - 1)); } public static int fun2(int a, int b) { if (b == 0) return 1; return fun(a, fun2(a, b - 1)); } public static void main(String[] args) { // Example usage } }
def fun(x, y): if y == 0: return 0 return x + fun(x, y - 1) def fun2(a, b): if b == 0: return 1 return fun(a, fun2(a, b - 1))
function fun(x, y) { if (y === 0) return 0; return x + fun(x, y - 1); } function fun2(a, b) { if (b === 0) return 1; return fun(a, fun2(a, b - 1)); }
x*y
x+x*y
xy
yx
This question is part of this quiz :
Top MCQs on Recursion Algorithm with Answers