We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fa762b4 commit cff8321Copy full SHA for cff8321
algorithms/tests/test_math.py
@@ -1,5 +1,6 @@
1
import unittest
2
from ..math.extended_gcd import extended_gcd
3
+from ..math.lcm import lcm
4
5
6
class TestExtendedGCD(unittest.TestCase):
@@ -24,3 +25,16 @@ def test_extended_gcd(self):
24
25
# Find extended_gcd of 50 and 15
26
(a, b) = extended_gcd(50, 15)
27
self.assertIs(50 * a + 15 * b, 5)
28
+
29
30
+class TestLCM(unittest.TestCase):
31
+ def test_lcm(self):
32
+ # Find lcm of 16 and 20
33
+ r = lcm(16, 20)
34
+ self.assertEqual(80, abs(r))
35
36
+ # Find lcm for 20 and 16
37
+ r2 = lcm(20, 16)
38
39
+ # Checks that lcm function is commutative
40
+ self.assertEqual(r, r2)
0 commit comments