33 lines
712 B
Lua
33 lines
712 B
Lua
-- Write a function to determine whether a given number is prime.
|
|
--
|
|
-- Solution --------------------------------------------------------------------
|
|
function is_prime(x)
|
|
-- Your implementation here
|
|
end
|
|
|
|
-- Tests -----------------------------------------------------------------------
|
|
|
|
local luaunit = require("luaunit.luauint")
|
|
|
|
function test_1_is_not_prime()
|
|
luaunit.assertFalse(is_prime(1))
|
|
end
|
|
|
|
function test_2_is_prime()
|
|
luaunit.assertTrue(is_prime(2))
|
|
end
|
|
|
|
function test_15_is_not_prime()
|
|
luaunit.assertFalse(is_prime(15))
|
|
end
|
|
|
|
function test_441_is_not_prime()
|
|
luaunit.assertFalse(is_prime(441))
|
|
end
|
|
|
|
function test_563_is_prime()
|
|
luaunit.assertTrue(is_prime(563))
|
|
end
|
|
|
|
os.exit(luaunit.LuaUnit.run())
|