Let be the smallest positive integer divisible by all positive integers up to , inclusive. Let be divided by the largest power of it can evenly be divided by. What are the last 3 digits of ?
Details and Assumptions
The smallest positive integer divisible by all positive integers up to is . In this case, you would divide this number by the largest power of it can evenly be divided by ( ), and give the last three digits of the result, or .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
My python solution:
First, I generate a list of prime numbers (primes) up to 1 , 0 0 0 , 0 0 0 using the Sieve of Eratosthenes. I store them as Booleans to conserve memory; Trues are primes and Falses are not. Next, I calculate the greatest power of 1 0 that will divide n (zeros). This is directly dependent on the greatest power of 5 that divides n , which is the greatest power of 5 less than the bound of 1 , 0 0 0 , 0 0 0 . Finally, I calculate n (huge) by starting with 1 and multiplying the largest prime power for each prime up to 1 , 0 0 0 , 0 0 0 . I mod out 1 0 z e r o s + 3 however, because we only care about the last three digits before the long string of zeros at the end. All the time stuff is just the method I use to time my script (which ran in about 1.23 seconds).