TopCoder problem "Multiples" used in SRM 201 (Division II Level One)



Problem Statement

    

You are to create a class Multiples with a method number, which takes three ints: min, max, and factor.

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)
    
0
14
5
Returns: 3
The numbers 0, 5, and 10 are evenly divisible by 5, so this returns 3.
1)
    
7
24
3
Returns: 6
The numbers 9, 12, 15, 18, 21, 24 are evenly divisible by 3, so this returns 6.
2)
    
-123456
654321
997
Returns: 780
3)
    
-75312
407891
14
Returns: 34515

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=343

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=5872&pm=343

Writer:

zoidal

Testers:

lbackstrom , brett1479

Problem categories:

Brute Force, Simple Math