pull down to refresh
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);}
result = 2520;
for (i = 11; i <= 20; i++) {
if (result % i != 0)
result *= i / gcd(result, i);
}
where gcd is the greatest common divisor.
gcd
After this, result contains the number.
result
For an arbitrary range from 1..n, the complexity is O(n log n), if gcd uses the standard Euclidean algorithm.
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
gcdis the greatest common divisor.After this,
resultcontains the number.For an arbitrary range from 1..n, the complexity is O(n log n), if
gcduses the standard Euclidean algorithm.