7
2
Write a program that checks if a given positive integer can be represented as sum of two or more consecutive positive integers.
Example:
43 can be represented as 21 + 22
10 = 1+2+3+4
but 4 cannot be represented in this way.
Input spec: positive integer (as argument or stdin)
Output spec: truthy or falsy
Sample i/o
43 -> true
4 -> false
Shortest code wins.
Any odd number greater than 1 would return true? – elssar – 2012-09-05T12:48:29.643
I edited the question to be clearer, and only code-golf. – mbomb007 – 2016-03-11T15:05:02.987
Good edit, @mbomb007 – Timtech – 2016-03-11T15:57:37.723
Related OEIS sequence – MildlyMilquetoast – 2016-12-06T05:23:05.543
I assume
./check 1should returnfalse? – mellamokb – 2011-06-23T04:23:16.1401@mellamokb, I've fixed the spec and it's now clear that
1gives false. – Peter Taylor – 2011-06-23T09:24:22.453Is case important for the output? – Joey – 2011-06-24T11:12:37.107
Not really, that should not be a problem :) – Aman ZeeK Verma – 2011-06-24T11:57:11.077