Number of divisors in a given range
Submissions: 996   Accuracy:

57.9%

  Difficulty: Easy   Marks: 2

Given a range [m..n]. You task is to find the number of integers divisible by either a or b in the given range.

Input:
The first line of input consists of an integer T denoting the number of test cases.The next line consists of  four space seperated integers m, n, a, b where m and n denotes the range.

Output:
Print the number of integers divisible by a or b in the given range.

Constraints:
1<=T<=100
1<=m,n<=100000
1<=a,b<=500

Example:
Input:
2
5 11 4 6
3 1000 5 9
Output:
2
289

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Shubham Chaudhary
Author: Shubham Chaudhary gfg


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.