==> arithmetic/consecutive.sums.s <== Generalize to find X (and I) such that (X + X+1 + X+2 + ... + X+I) = T for any integer T. You are asking for all (X,I) s.t. (2X+I)(I+1) = 2T. The problem is (very) slightly easier if we don't restrict X to being positive, so we'll solve this first. Note that 2X+I and I+1 must have different parities, so the answer to the relaxed question is N = 2*(o_1+1)*(o_2+1)*...*(o_n+1), where 2T = 2^o_0*3^o_1*...*p_n^o_n (the prime factorization); this is easily seen to be the number of ways we can break 2T up into two positive factors of differing parity (with order). In particular, 20000 = 2^5*5^4, hence there are 2*(4+1) = 10 solutions for T = 10000. These are (2X+I,I+1): (32*1,5^4) (32*5,5^3) (32*5^2,5^2) (32*5^3,5) (32*5^4,1) (5^4,32*1) (5^3,32*5) (5^2,32*5^2) (5,32*5^3) (1,32*5^4) And they give rise to the solutions (X,I): (-296,624) (28,124) (388,24) (1998,4) (10000,0) (297,31) (-27,179) (-387,799) (-1997,3999) (-9999,19999) If you require that X>0 note that this is true iff 2X+I > I+1 and hence the number of solutions to this problem is N/2 (due to the symmetry of the above ordered pairs).