Consider the following recursive Java function f that takes two long arguments and returns a float value: public static float f (long m, long n) { float result = (float)m / (float)n; if(m < 0 | n < 0) return 0.of; else result - = f(m * 2,n * 3); return result ; } Which of the following real values best approximates the value of f (1, 3) ?
Consider the following recursive Java function f that takes two long arguments and returns a float value: public static float f (long m, long n) { float result = (float)m / (float)n; if(m < 0 | n < 0) return 0.of; else result - = f(m * 2,n * 3); return result ; } Which of the following real values best approximates the value of f (1, 3) ? Correct Answer 0.2
The correct answer is option 1.
Key Points
The function f(1,3) pass the values to m,n. Then the value will typecast to float and result=0.3333. Then it enters into else statement the function f is f(2,9).
And finally it returns result as 0.20000003.
∴ Hence the correct answer is 0.2.
মোঃ আরিফুল ইসলাম
Feb 20, 2025