Statement from explanation of "What is the smallest number divisible by each of the numbers 1 to 20?" on Project Euler

77 Views Asked by At

Here is part of explanation from the PE problem 5:

Let us consider the case of finding the least value of $N$ for $k=20$. We know that $N$ must be divisible by each of the primes, $p[i]$, less than or equal to $k$. But what determines the exponent, $a[i]$, in the prime factorisation of $N$ is the greatest perfect power of $p[i]$ that is less than or equal to $k$. For example, as $2^4=16$ and $2^5=32$, we know that $a[1]=4$ as no other numbers, $2≤j≤20$, can contain more than four repeated factors of $2$. Similarly $3^2=9$ and $3^3=27$, so $a[2]=2$. And for $p[i]≥5, a[i]=1.$

It seems I intuitively understand the statement marked in bold but how do I prove it more strictly?

1

There are 1 best solutions below

2
On BEST ANSWER

Greatest power of the number which is still not larger than the other number. For example take number 3. What we want to do is then to solve the equation $3^x = 20$. You can calculate that as $\lfloor \log_3(20) \rfloor$ where $\log_3(20) \approx 2.7268$.

In other words; the largest integer which if you put it into the exponent of the prime does not get larger than that other number. $3^2 = 9 < 20$, but $3^3 = 27 > 20$ so having $3^3$ as a factor would be overkill, but $3^2$ would be necessary.


Ok another explanation. Think of it as the number has a bunch of buckets assigned to it. One bucket where we store our 2s, one with 3s, one with 5s and so on. We need to have as many of each so that we can gather our numbers and "build" a product of any number up to 20. We are not interested in building numbers larger than 20. Therefore if we had more than 4 twos, the fifth two would never be used. And since we wanted the smallest possible number having unnecessary building blocks makes it unnecessarily large.