while loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

while loop

how to make, input: 10 output : 10 + 8 + 6 + 4 + 2 + 0 = 30 using while. please help๐Ÿ˜Š๐Ÿ˜Š. thanks

14th Oct 2016, 12:10 PM
Angel
Angel - avatar
2 Answers
+ 2
i = int(input()) sum = 0 while i > 0: sum += i i -= 2 print(str(sum))
14th Oct 2016, 12:22 PM
Zen
Zen - avatar
0
its output is an even number of inputs countdown until 0 thanks before
14th Oct 2016, 12:33 PM
Angel
Angel - avatar