Problem Statement
You are to create a class Multiples with a method number, which takes three
Given a range of integers from min to max (inclusive), determine how many numbers within that range are evenly divisible by factor.
Definition
- Class:
- Multiples
- Method:
- number
- Parameters:
- int, int, int
- Returns:
- int
- Method signature:
- int number(int min, int max, int factor)
- (be sure your method is public)
Notes
- If x is evenly divisble by y, there exists some integer k such that k * y = x.
Constraints
- min will be between -1000000 and 1000000, inclusive.
- max will be between -1000000 and 1000000, inclusive.
- max will be greater than or equal to min.
- factor will be between 1 and 1000, inclusive.
Examples
0
14
5
Returns: 3
The numbers 0, 5, and 10 are evenly divisible by 5, so this returns 3.
7
24
3
Returns: 6
The numbers 9, 12, 15, 18, 21, 24 are evenly divisible by 3, so this returns 6.
-123456
654321
997
Returns: 780
65456
456789
13
Returns: 30102
798125
987546
789
Returns: 240
15231
42342
324
Returns: 83
784536
789415
358
Returns: 14
-706454
89124
841
Returns: 946
-75312
407891
14
Returns: 34515
-1000000
1000000
1
Returns: 2000001
-1000000
1000000
1000
Returns: 2001
45612
761323
2
Returns: 357856
1000000
1000000
4
Returns: 1
1000000
1000000
3
Returns: 0
-1000000
-100000
7
Returns: 128572
-1000000
-999999
2
Returns: 1
-4
4
5
Returns: 1
2
5
1
Returns: 4
0
1000
2
Returns: 501
10
10
5
Returns: 1
-3
-2
5
Returns: 0
-5
-1
5
Returns: 1
2
10
2
Returns: 5
-1
-1
2
Returns: 0
4
6
1
Returns: 3
4
5
12
Returns: 0
7
8
8
Returns: 1