Enumerate the exercises

This commit is contained in:
2023-12-11 16:13:48 +00:00
parent 3558a24b47
commit 3052288380
13 changed files with 4 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
-- The greatest common divisor (GCD) of two numbers is, as the name
-- suggests, the largest number which evenly divides both. Implement
-- the function below to calculate this. It's recommended that you
-- use Euclid's algorithm but feel free to use another approach if you
-- want.
--
-- Solution --------------------------------------------------------------------
function greatest_common_divisor(x, y)
-- Your implementation here
end
-- Tests -----------------------------------------------------------------------
local luaunit = require("luaunit.luaunit")
function test_greatest_common_divisor_of_1386_and_3213_is_63()
luaunit.assertEquals(greatest_common_divisor(1386, 3213), 63)
end
function test_greatest_common_divisor_of_1470_and_3234_is_294()
luaunit.assertEquals(greatest_common_divisor(1470, 3234), 294)
end
function test_greatest_common_divisor_of_931_and_399_is_133()
luaunit.assertEquals(greatest_common_divisor(931, 399), 133)
end
os.exit(luaunit.LuaUnit.run())