0878. Nth Magical Number
https://leetcode.com/problems/nth-magical-number
Description
A positive integer is magical if it is divisible by either a
or b
.
Given the three integers n
, a
, and b
, return the nth
magical number. Since the answer may be very large, return it modulo 109 + 7
.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= n <= 109
2 <= a, b <= 4 * 104
ac
Last updated