Three Numbers

Given three positive numbers A, B, and C.
Find the number of positive integers less than D that are divisible by either of A, B or C.

 

Input Format

The 1st argument given is an Integer A.
The 2nd argument given is an Integer B.
The 3rd argument given is an Integer C.
The 4th argument given is an Integer D.

Output Format

Return an Integer X, the number of positive integers that are divisible by either of A, B, or C.

Constraints

1 <= A, B, C, D <= 1e9

For Example

Input:
    A = 2
    B = 3
    C = 4
    D = 10
Output:
    6
   
Explanation:
    positive numbers less than D that are divisible by either of A, B or C are
	2, 3, 4, 6, 8, 9
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.
Start solving Three Numbers on Interview Code Editor
Sign Up
to access hints and editorial solutions for Three Numbers

Discussion


Loading...
Click here to start solving coding interview questions