Where is my logic wrong?

Link to question

Link to solution

All except one test case is passing. where is the logic flawed?

int overflowed


Tried with unsigned long long. Still the same test case is failing.

you need to change also these lines:

 if(len%2 == 0) 
    result += (len/2)*(len+1);
    result += len*((len+1)/2);

check this