One more person added to the winners list and it 's time to post the solution. Congratulations to all who participated, I hope you had a lot of fun
The key to the answer is the question "which persons are going to toggle a given locker?". The answer to this becomes obvious after a bit of trial, for example locker number 8 will be visited only by persons 1,2,4 and 8.
Only the persons with number being a factor of the locker 's number will visit and toggle a given locker! The only way for a locker to end up open is if an
odd # of people visit the locker. (because they start closed and if it 's an even # they 'll end up closed again)
The only set of numbers who have an odd # of factors are square numbers (why? because one of the multiplication pairs is composed by the same number e.g. 3x3 -> 1 number).
So, the next question becomes, how many square numbers are there up to 20? That 's easy , you can count them. But how many are there in a billion? That 's also easy! Remember, a sqare number is x^2 (e.g. 16 is
4^2). Well, how many other square numbers exist up to that? Obviously 4 (1^2, 2^2, 3^2, and 4^2)
So, to find how many square numbers there are in 1 billion, we just take the square root of 1 billion, and round it down to the closest integer ->
31622. Indeed, 31622^2 = 999.950.884 while 31623^2 = 1.000.014.129 > 1 billion. So there are 31622 squares (and open lockers) in one billion
