Browse Source

added test for lcm (lowest common multiple) as well as corresponding functionality

remotes/origin/feature/feature-fractions
fdai7764 11 months ago
parent
commit
3c6ad1adbe
  1. 5
      src/main/py/more_advanced_calculations.py
  2. 3
      src/test/py/test_more_advanced_calculations.py

5
src/main/py/more_advanced_calculations.py

@ -3,4 +3,7 @@ def gcd(a,b):
if a < b:
(a,b) = (b,a)
a -= b
return a
return a
def lcm(a,b):
return (a * b) / gcd(a,b)

3
src/test/py/test_more_advanced_calculations.py

@ -12,6 +12,9 @@ class more_advanced_calculations(unittest.TestCase):
def test_gcd_of_747_and_81_should_be_9(self):
self.assertEqual(gcd(747,81), 9)
def test_lcm_of_5_and_7_should_be_35(self):
self.assertEqual(lcm(5,7), 35)
if __name__ == '__main__':

Loading…
Cancel
Save