Module: (Python) Conditional loop statement - WHILE


Problem

15 /21


The sum of the elements of the sequence

Theory Click to read/hide

Task

The input of the program is the data stream — a sequence of integers that ends in zero (zero is not included in the sequence). You need to find the sum of the elements of this sequence.
 
Solving algorithm
 sum=0
 input x // enter the first number
 while x != 0 // the input end sign is set in the condition,
 nc // that is, until you enter zero
   sum = sum + x // you can do something with the original number.
                  // You can add a number check for some condition, etc.
   input x // enter the next number
 kts
 print sum //result output

Problem

The input of the program receives a data stream — a sequence of integers that ends in zero (zero is not included in the sequence). It is required to find the sum of the elements of this sequence.

Input
The input to the program is numbers, one number per line.

Imprint
Print the answer to the problem.
 

 

Examples
# Input Output
1 1
2
3
0
6