Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Count Consecutive Summers solution in Clear category for Count Consecutive Summers by IRONKAGE
def count_consecutive_summers(num):
count = 0
for n in range(0, num):
denominator = num - n * (n + 1) // 2
if denominator <= 0:
break
if denominator % (n + 1) == 0:
count += 1
return count
if __name__ == '__main__':
print("Example:")
print(count_consecutive_summers(42))
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!")
Oct. 11, 2019