pull down to refresh

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

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