Demo entry 6758242

Use a counting-down while loop


Submitted by anonymous on Aug 09, 2018 at 18:50
Language: Python. Code size: 165 Bytes.

#Use a counting-down while loop
def while_loop_sum(n):
    total = 0
    while (n > 0):
        total += n
        n -= 1
    return total


This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).