#=======================================================================
# Author: Isai Damier
# Title: Lowest Common Multiplier
# Project: geekviewpoint
# Package: algorithms
#
# Statement:
# Find the lowest common multiplier of the given numbers
#
# Sample Input: 24, 16
# Sample Output: 48
#
# Description: This function computes the lowest common multiplier of
# two given numbers. The lcm of two numbers a and b is the smallest
# number that can be divided by both a and b. For example, 15 is the
# lcm of 3 and 5 because 15 is the lowest number that can be evenly
# divided by both 3 and 5; 18 is the lcm of 6 and 9 because 18 is the
# lowest number that can be divided by both 6 and 9.
#
# Technical Details: Mumerous techniques have been developed to compute
# the lcm of two numbers. The present algorithm uses
# (a*b)/gcd(a,b) = lcm (a,b).
#
# GCD: http://www.geekviewpoint.com/python/number/gcd
#=======================================================================
def LCM( a, b ):
if a > b:
return a / GCD( a, b ) * b
else:
return b / GCD( a, b ) * a

import unittest
from algorithms import numbers as algorithm
class Test( unittest.TestCase ):
def testGCD( self ):
self.assertEquals( 8, algorithm.GCD( 24, 16 ) )
self.assertEquals( 8, algorithm.GCD( 16, 24 ) )
self.assertEquals( 16, algorithm.GCD( 16, 16 ) )
self.assertEquals( 1, algorithm.GCD( 13, 29 ) )