Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Done solution in Clear category for Count Consecutive Summers by nikita.dzhigir
def count_consecutive_summers(num):
count = 0
for i in range(1, num + 1):
s = 0
for j in range(i, num + 1):
s += j
if s == num:
count += 1
break
return count
if __name__ == '__main__':
print("Example:")
print(count_consecutive_summers(42))
# These "asserts" are used for self-checking and not for an auto-testing
assert count_consecutive_summers(42) == 4
assert count_consecutive_summers(99) == 6
assert count_consecutive_summers(1) == 1
print("Coding complete? Click 'Check' to earn cool rewards!")
Dec. 19, 2018