Question PSC-FUNC-0072
HardWhat will be the output of the following pseudocode?
Function sumDigits(Integer n)
if (n == 0) return 0 end if
return n mod 10 + sumDigits(n / 10)
End Function
Function root(Integer n)
if (n < 10) return n end if
return root(sumDigits(n))
End Function
Print root(99999), root(123456789)
- A.
45 45
- B.
9 45
- C.
Sign up free to see the answer and a step-by-step explanation.