Recursive Multiplication Algorithm
Consider the following recursive function.
function mystery(x, y)
{
if (y == 0)
return 0;
else if (y % 2 == 0)
return mystery(x + x, y / 2);
else
return x + mystery(x + x, (y - 1) / 2);
}
What mathematical operation is performed by the call mystery(x, y)?
A
Integer division of x by y
B
Exponentiation (x raised to power y)
C
Multiplication of x and y
D
Logarithm of y with base x
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | djy181023 | 1 | 1 | 1m 29s | 11 |
| #2 | jasonvikathompson | 1 | 2 | 1m 29s | 1 |
| #3 | jdvillalta865 | 1 | 5 | 1m 57s | -57 |
Items per page:
10
1 – 3 of 3
APFIVE