Login or Create an Account to view the mark scheme, comment, and add to a test
Consider the following recursive method called mystery(n) which takes one integer parameter called n.
[4]mystery(n)
if n < 10 then
if n mod 2 = 0 then
return 1
else
return 0
end if
else
l = n mod 10
if l mod 2 = 0
return 1 + mystery(n div 10)
else
return mystery(n div 10)
end if
end if
end mystery
Determine (showing each step to reach the result) the value of variable X after execution of the following method call:
X = mystery(23674)
Short Answer4 MarksPremium
9 Uses9 Views0 Likes