n, p, q and r. Consider, in increasing order, every positive integer divisible by at least one of p, q or r.
Return the n-th number of this sequence (counting from 1). The answer is guaranteed not to exceed 2·10⁹.
Walking through the numbers one by one is too slow, since the answer can be huge.n=5, p=3, q=4, r=6 → 9
The matching numbers are 3, 4, 6, 8, 9, 12, … and the fifth is 9.
n=4, p=5, q=5, r=7 → 14
Divisors may repeat. The matches are 5, 7, 10, 14, … so the fourth is 14.
n=6, p=2, q=9, r=10 → 10
n=5, p=3, q=4, r=6
9
Run checks the first 3 tests in your browser. Submit checks all 124 tests on the server, hidden ones included.