Find number in interval with small prime factors

58 Views Asked by At

Given two natural numbers A and B where A + 1 < B, and a prime number P with P < A.

Is there a natural number X with A < X < B with prime factors p_i which are all p_i <= P?

Examples (table of prime factors):

  • A=15, B=17, P=2 gives X=16=2^4
  • A=100, B=109, P=7 gives X=105=3*5*7 or X=108=2^2*3^3
  • A=216, B=225, P=5 has no such X

Naive solution: Enumerate all candidates X_c with A < X_c < B, and check their prime factors to be all less than / equal to P.

Is there a better way of finding an X (perhaps with some probability)? Or some way of saying whether there exist such an X? Or some probability of whether there exist such an X?