Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Simple Lua primality test
--lua 5.3 local function isPrime(num) assert(math.type(num) == "integer", "argument is not an integer") assert(num >= 2, "argument must be 2 or greater") for i = 2, math.floor(math.sqrt(num)) do if num % i == 0 then return false end end return true end for i = 2, 1000 do if isPrime(i) then io.write(i, " ") end end local x = io.read("*n") io.write("\n\n", x, " is a prime: ", tostring(isPrime(x)))
run
|
edit
|
history
|
help
0
Binary to Integers / Integers to Binary
MXR
10 Line challenge
BasicTablePrinterV2
PAID HACK PuBG
Random number generation with ranges (Lua)
hack
For your YouTube comment section. (updated)
ok
Hakusu