← Questions
Count ways to write N as a sum of consecutive positive integers
0
I was asked this
No reports yet. Sign in to say where you were asked it.
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.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding
