We use the formula for the sum of arithmetic progression.
a) If n is odd, then the sum of n consecutive integers is divisible by n. So, if the number 1+2+...+(n+1)=2n+1⋅(n+2) was the sum of n consecutive integers, it would be divisible by 2n+1 and by n. As n+1 and n are relatively prime, the same clearly holds for 2n+1 and n. Therefore, 2n+1⋅(n+2) should be divisible by 2n+1⋅n, meaning that n+2 should be divisible by n.
If n is even, the sum of n consecutive integers is divisible by 2n. So, if 1+2+...+(n+1)=(n+1)⋅2n+2 was the sum of n consecutive integers, it would be divisible by both n+1 and 2n. As n+1 and n are relatively prime, also n+1 and 2n are relatively prime. Thus, (n+1)⋅2n+2 should be divisible by (n+1)⋅2n, implying that n+2 is divisible by n.
So, in all cases n+2 is divisible by n, which is equivalent to saying 2 is divisible by n. So, n=1 or n=2. Clearly 1+2 is the sum of one integer, but 1+2+3=6, being an even number, cannot be represented as the sum of two consecutive integers.
b) If a is the first of the two consecutive integers, then the problem can be represented as the equation (a+a+n)(n+1)/2=(a+n+1+a+2n)n/2. By simplifying we see that it is equivalent to a=n2. This means that the sum of n+1 consecutive integers, first of which is n2, is the sum of the next n consecutive integers. So, the desired numbers exist for every n.