From 3c6ad1adbe48bda1feb0c32693960ee432a82b70 Mon Sep 17 00:00:00 2001 From: fdai7764 Date: Fri, 19 Jan 2024 12:33:58 +0100 Subject: [PATCH] added test for lcm (lowest common multiple) as well as corresponding functionality --- src/main/py/more_advanced_calculations.py | 5 ++++- src/test/py/test_more_advanced_calculations.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/py/more_advanced_calculations.py b/src/main/py/more_advanced_calculations.py index 449119c..b6b77f9 100644 --- a/src/main/py/more_advanced_calculations.py +++ b/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 \ No newline at end of file + return a + +def lcm(a,b): + return (a * b) / gcd(a,b) \ No newline at end of file diff --git a/src/test/py/test_more_advanced_calculations.py b/src/test/py/test_more_advanced_calculations.py index 720df91..f4580d2 100644 --- a/src/test/py/test_more_advanced_calculations.py +++ b/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__':