If you're like me, you lose a crap ton of pencils.
Most of the time, I lose them one at a time- but how many pencils have I lost in my pencil-losing career total?
Write a function that takes in pencils I had yesterday, 'end', and then returns how many I have lost cumulatively.
I will never keep more than 20 pencils on me, because that's just insane. So the variable end will only be measured in integers less than 20.
Examples:
lostPencils(6)
21
lostPencils(8)
36
def lostPencils(end):
result = 0
current = 1
while current <= end:
result += current
current += 1
return result
test.assert_equals(lostPencils(10), 55)
test.assert_equals(lostPencils(2), 3)
test.assert_equals(lostPencils(5), 15)