News for hackers. Stuff that matters.
Re:I cheated on my Microsoft interview (2019) by AlchemistCamp on Sunday June 05, 2022 @06:09AM (#31629569)
It's not even a trick, though. The sum of zero and n is n. The sum of 1 and n-1 is also n. So is the sum of 2 and n-2, and so on. There are n+1 numbers when counting from zero to n, and they can be paired so that each pair adds up to n.

It's a pretty obvious thing that anyone who spent much time thinking about math as a kid or teenager would have encountered, and maybe that's who MS wanted to hire! Especially back then when more of their programming needs dealt with algorithms and mathematical thinking, as opposed to gluing libraries together, I think it makes some sense.

Re:I cheated on my Microsoft interview (2019) by anonymousDan on Sunday June 05, 2022 @06:31AM (#31629691)
Isn't this the famous Gauss proof/algorithm that he came up with when he was 5 or something?
Re:I cheated on my Microsoft interview (2019) by AlchemistCamp on Sunday June 05, 2022 @07:02AM (#31629841)
I'm sure he got there earlier than almost anyone!

Just googled it, and it looks like he did is a little differently. He paired 1 with n and then 2 with n-1, etc... yielding n/2 pairs that add up to n+1. It still works out to (n+1) * n/2, though :)

Apparently biographers disagreed about his age at the time but they all had the same method and the same problem of summing numbers from 1 to 100.

Re:I cheated on my Microsoft interview (2019) by zeroonetwothree on Sunday June 05, 2022 @10:34AM (#31631331)
That story is apocryphal.