Question PSC-FUNC-0040
EasyWhat will be printed by the following pseudocode?
Function digitSum(Integer n)
if (n == 0)
return 0
end if
return n mod 10 + digitSum(n / 10)
End Function
Function root(Integer n)
if (n < 10)
return n
end if
return root(digitSum(n))
End Function
Print root(9875)
- A.
9
- B.
29
- C.
Sign up free to see the answer and a step-by-step explanation.