Approach hintTry it first, then revealHide
The smallest valid sum for a given k is k(k+1)/2, and every valid n differs from it by a multiple of k. Write n as a power of two times an odd number and test the two natural candidates that this split suggests.