TopCoder problem "LCMRange" used in SRM 162 (Division II Level One)



Problem Statement

    The least common multiple of a group of integers is the smallest number that can be evenly divided by all the integers in the group. Given two ints, first and last, find the least common multiple of all the numbers between first and last, inclusive.
 

Definition

    
Class:LCMRange
Method:lcm
Parameters:int, int
Returns:int
Method signature:int lcm(int first, int last)
(be sure your method is public)
    
 

Constraints

-first will be between 1 and 12, inclusive.
-last will be between first and 12, inclusive.
 

Examples

0)
    
1
5
Returns: 60
The following statements show how 60 can be divided by all numbers from 1 to 5:

1*60 = 60

2*30 = 60

3*20 = 60

4*15 = 60

5*12 = 60
1)
    
4
5
Returns: 20
Although 60 would be a common multiple for 4 and 5, 20 is the least common multiple.
2)
    
1
12
Returns: 27720

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=4615&pm=1792

Writer:

schveiguy

Testers:

lbackstrom , brett1479

Problem categories:

Brute Force, Math