Question PSC-FUNC-0023
EasyWhat will be the output of the following pseudocode?
Function sumTo(Integer n)
if (n == 0)
return 0
end if
return n + sumTo(n - 1)
End Function
Print sumTo(6)
- A.
15
- B.
21
- C.
Show answer and explanation
Answer: B
6 + 5 + 4 + 3 + 2 + 1 + 0 = 21.