pull down to refresh

232,792,560?

2520 is divisible by 1..10, but not 11.
To make a number divisible by the numbers 11 to 20 in addition to 2520, it needs to be additionally divisible by the primes between 11..20, which are 11, 13, 17 and 19, and by 16 (2^4), because 2520 is already divisible by 12 (2^2*3), 14 (2*7), 15 (3*5), 16/2=8 (so one "2" is missing in the factorization), 18 (2*3^2)and 20 (2^2*5).

So the result is 2520 * 11 * 13 * 2 * 17 * 19 = 232,792,560

Or to spell it out as a factorization:
2^4 * 3^2 * 5 * 7 * 11 * 13 * 17 * 19

BTW interesting synchronicity - I saw the number 2520 earlier today in this article: https://medium.com/@syndyne.invents/from-structure-to-meaning-8700317ef6dd

Good job, very elegant and I like how you didn't use code.

reply

If I were to use code, I'd do it like this:

result = 2520;
for (i = 11; i <= 20; i++) {
if (result % i != 0)
result *= i / gcd(result, i);
}

where gcd is the greatest common divisor.

After this, result contains the number.

For an arbitrary range from 1..n, the complexity is O(n log n), if gcd uses the standard Euclidean algorithm.

reply

nice solve, thank you for sharing

reply