Browse Source

added test for greatest common divisor (gcd) as well as corresponding functionality

remotes/origin/feature/feature-fractions
fdai7764 11 months ago
parent
commit
d5aeb0fe42
  1. 6
      src/main/py/more_advanced_calculations.py
  2. 18
      src/test/py/test_more_advanced_calculations.py

6
src/main/py/more_advanced_calculations.py

@ -0,0 +1,6 @@
def gcd(a,b):
while a != b:
if a < b:
(a,b) = (b,a)
a -= b
return a

18
src/test/py/test_more_advanced_calculations.py

@ -0,0 +1,18 @@
import unittest
from src.main.py.more_advanced_calculations import *
class more_advanced_calculations(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_gcd_of_747_and_81_should_be_9(self):
self.assertEqual(gcd(747,81), 9)
if __name__ == '__main__':
unittest.main()
Loading…
Cancel
Save