Create greatest common divisor exercise
This commit is contained in:
parent
01681dae61
commit
c41bd07c6c
23
greatest_common_divisor.lua
Normal file
23
greatest_common_divisor.lua
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-- 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())
|
Loading…
x
Reference in New Issue
Block a user