Why this code is giving wrong answer? Can anyone spot the mistake?

https://www.codechef.com/viewsolution/53419217

Use integer division

//

Instead of normal division

/
1 Like

Hey. This solution worked… One more question… N*(N+1) is always divisible by 2… right? Then why It’s giving wrong answer without using integer division?

Yes you are right that N*(N+1) is divisible by 2. But, in python using ‘/’ will return a floating point answer while ‘//’ will return an integer.

Ohh… Got it. I didn’t think about it. Thanks!