logoalt Hacker News

j16sdizyesterday at 5:43 PM1 replyview on HN

The first thing I had in mind was: the final answer needed to be /2. keeping the number before dividing not overflowing needs some tedious work


Replies

trehaloseyesterday at 5:47 PM

It's not very tedious. Instead of dividing the product by 2, you can just divide whichever of x or x+1 is even by 2 before multiplying.