Write a recursive function that calculates the sum of the elements of a sequence of integers given not its input. The input ends with the number 0. The main program must contain a function call and a result output. Loops are not allowed
Input: The input lines contain integers, one per line. The last line contains the number 0.
Output: The program should output a single number – the sum of all elements of the sequence.
Examples
# |
Input |
Output |
1 |
1
2
3
0 |
6 |
Запрещенные операторы:for;while;until