**Problem Description**

Given three positive integers **A**, **B** and **C**.

Any positive integer is magical if it is divisible by either **B** or **C**.

Return the **A ^{th}** magical number. Since the answer may be very large, return it modulo

1 <= A <= 10^{9}

2 <= B, C <= 40000

The first argument given is an integer **A**.

The second argument given is an integer **B**.

The third argument given is an integer **C**.

Return the **A ^{th}** magical number. Since the answer may be very large, return it modulo

Input 1:

A = 1 B = 2 C = 3

Input 2:

A = 4 B = 2 C = 3

Output 1:

2

Output 2:

6

Explanation 1:

1st magical number is 2.

Explanation 2:

First four magical numbers are 2, 3, 4, 6 so the 4th magical number is 6.

NOTE:You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.

Sign Up

to access hints and editorial solutions for**Ath Magical Number**

to access hints and editorial solutions for

Loading...