News for hackers. Stuff that matters.
Re:I cheated on my Microsoft interview (2019) by Sesse__ on Sunday June 05, 2022 @08:50AM (#31630523)
Or you can assume N is less than 2^31, and clear out the top bit in the final answer (because that's the only place the wrong values can come from). Which is admittedly pretty hackish, but…

Edit: The simplest solution is probably just doing (n/2)*(n+1) (assuming n is even; move the division for n odd).

There are no comments on this comment yet.