If x and y are really large, so it is not viable to iterate over all numbers from 1 to x, you can instead simply decompose y and calculate for each simple factor whether its maximum power in y will also divide x !.
.
:
bool max_power_of_p_in_fac(int p, int n) {
int mu = 0;
while (n/p > 0) {
mu += n/p;
n /= p;
}
return mu;
}
bool y_divides_x_fac(int y, int x) {
for each prime factor p^q of y:
if (max_power_of_p_in_fac(p, x) < q)
return false;
return true;
}
x < y O ( y + log x * # y).
, y O (log y) . , - O (y ^ (1/4) + log x * log y)
, :
