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
VERSION
Basic Lehmer RNG implementation using closures
Newton-Raphson method for the square root
Weight system (Will make a C# one soon too!)
ShSlotMachine_Data
Replace all substring in string
roulette
PAID HACK PuBG
10 Line challenge
Dirty Bag 'o Tokens Maker