Problem Statement
You will be given a int[] a and two ints lower and upper. Return the number of integers between lower and upper, inclusive, that are multiples of all members of a.
Definition
- Class:
- CommonMultiples
- Method:
- countCommMult
- Parameters:
- int[], int, int
- Returns:
- int
- Method signature:
- int countCommMult(int[] a, int lower, int upper)
- (be sure your method is public)
Constraints
- a will contain between 1 and 50 elements, inclusive.
- Each element of a will be between 1 and 100, inclusive.
- upper will be between 1 and 2000000000 (2*109), inclusive.
- lower will be between 1 and upper, inclusive.
Examples
{1,2,3}5
15
Returns: 2
The only numbers between 5 and 15 that are multiples of 1, 2 and 3 are 6 and 12.{1,2,4,8,16,32,64}128
128
Returns: 1
128 is a multiple of all smaller powers of 2.{2,3,5,7,11,13,17,19,23,29,31,37,41,43,49}1
2000000000
Returns: 0
{1,1,1}1
2000000000
Returns: 2000000000