There is a number divisible by all integers from 1 to 200, except for two consecutive numbers. What are the two?

Excellent question! The answer is $127$ and $128$... but why? If you wanted to find a number divisible by $1,2,3,4$ you might first multiply these numbers and say $24$. However, you soon realize $4$ is already a multiple of $2$; you can use just $3\times4$ to get $12$. Therefore, you need only multiply the largest powers of the primes that factor all of the digits from $2$ to $200$ to get a number that is divisible by all of the integers from $1$ to $200$.

If you do this; you will find the number is $2^7\cdot3^4\cdot5^3\cdot7^2\cdot11^2\cdot13^2\cdot17\cdot19\cdot23\cdot29\cdot\ldots$(the rest of the primes up to $199$) = a very large number.

Next we need to find a restriction to eliminate two consecutive numbers. One of the two numbers must be even. The only way to remove an even number from the above calculation without modifying any of the other primes is to reduce the power of $2^7$ to $2^6$; this removes the number $128$ from the list. Since $127$ is also a prime number, it can also be removed from the list without affecting any of the other primes in the list...

I hope this helps.


Hint: Think about how many factors of $2$ the number will have and find a prime nearby.


Thought process (likely partially reversed order):

  • $m<200<2m\implies m>100$
  • if $m$ doesn't divide by a higher prime power than other numbers, for at least one prime, then its factorization, can be made up for by other numbers.
  • 243 is the next power of 3 after 81, that's too large (and that happens for all other powers for larger primes), and 162 fails at escaping 81.
  • largest power of 2, in the range of a factorization is $2^7=128$, which is too large for other primes (including another 2) to be added.
  • $129=3×43\implies (127,128)$

Edit

Second point was this:

  • If $$m=p^x\cdot q^y$$ then its factorization, can be made up for by the product of a number that has $p^x$ in its factorization, and another that has $q^y$ in its factorization. It follows that, if at least one of $x,y$ aren't unique to $m$, then $m$ is a divisor of $n$

Since you specifically mentioned trying to solve this problem computationally, I hope it's okay to post some Python code even though we're not on StackOverflow.

As long as you're working with standard unbounded integers, Python shouldn't have any problem calculating lcm for large numbers or checking divisibility. It wouldn't work with floats (e.g. 1.3279275150902608e+87) or numpy fixed-size integers.

from functools import reduce
from math import gcd


def lcm(x, y):
    return x * y // gcd(x, y)


N = 200
for i in range(1, N+1):
    # Testing i and i + 1
    all_except_two = list(range(1, i)) + list(range(i + 2, N + 1))
    lcm_all_except_two = reduce(lcm, all_except_two)
    divisible_by_i = (lcm_all_except_two % i == 0)
    divisible_by_i_plus_one = (lcm_all_except_two % (i + 1) == 0)
    if not divisible_by_i and not divisible_by_i_plus_one:
        print(f"{lcm_all_except_two}\nisn't divisible by either {i} or {i+1}.")

It outputs:

1327927515090260884407345538562367745796828278681721394601759928808007945120777126248000 isn't divisible by either 127 or 128.

in a few milliseconds. It also works for N=500.