Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Arithmetic approach solution in Clear category for Count Consecutive Summers by tokyoamado
def can_consecutive(x, d):
q, m = divmod(x, d)
if d % 2 == 1:
return m == 0 and q > (d - 1) / 2
else:
return m == d // 2 and q > d / 2 - 1
def count_consecutive_summers(num):
return sum(can_consecutive(num, d) for d in range(1, num + 1))
Dec. 12, 2018