Skip to content

Instantly share code, notes, and snippets.

@muayyad-alsadi
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muayyad-alsadi/643b2860e82ac1e1ce80 to your computer and use it in GitHub Desktop.
Save muayyad-alsadi/643b2860e82ac1e1ce80 to your computer and use it in GitHub Desktop.
primes in lua
function get_primes (n)
compo={}
primes={}
for i=2,n do
if not compo[i] then
primes[i]=true
for j=i*2,n,i do
compo[j]=true
end
end
end
return primes
end
for k,v in pairs(get_primes(10000)) do
print(k)
end
t0=os.clock()
for i=0,500 do
get_primes(10000)
end
print(os.clock()-t0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment