Count ways to write N as a sum of consecutive positive integers

0
Remix

Given n, count how many ways it can be written as a sum of one or more consecutive positive integers. A run of k numbers starting at a sums to k*a + k*(k-1)/2, so try each k while k*(k+1)/2 <= n and check whether a comes out a positive whole number.

AirbnbCodingLast asked Apr 2026
No answer yet. Write the first one; the best answer gets endorsed.