Puzzle time - factorials
-
Consider the following product of factorials: 100! x 99! x 98! x . . . x 2! x 1!.
Call each of the 100 factorials K! a "term" (e.g 78! is a term). Can you remove one term and leave a perfect square?
-
:::
OK, so according to my three lines of code, you have to remove 50!.
But I guess the more interesting challenge is to see that without brute force.
I guess the key is that there are many squares in these products, since (n+1)!n! = (n!^2)(n+1).
So we could write the product as something like
(1!^2*2) * (3!^2 * 4) * (5!^2 * 6) * ... * (99!^2 * 100)
Hmm...
:::
-
:::
I first noticed that primes above 50 appear an even number of times, and at least the higher primes below 50 appeared an odd number of times. Therefore I figured it had to be 48, 50, or 52. I then figured of the three 50 was the most likely answer and confirmed it with code.
Then I thought there must be an easier way.
So if you think of this as 100*(99!)^2 * 98*(97!)^2... 2*(1!)^2 you can reduce it to
(some huge perfect square) * 100 * 98 * 96... * 2Then you pull out a 2 from each factor and get 2^50*(50!). So yeah, exclude the 50! and you have a perfect square.
:::