generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Prime Numbers Competition

Previous Thread :: Next Thread 
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
27 Feb 2012 10:35 AM
Yes, I know there was previously a competition exactly like this; sorry. I can't find it any more but I'm really in competition mode for sharing my prime number-finding script.

Well, here are the rules:

No encryptions.
Must find 100% prime numbers, nothing else.
Standered prime numbers, not other types.
You must start finding prime numbers with 0.
No finding loopholes.
Script must be readable.
Make in RBX.Lua.
It must have a variable number value starting at 0 and added by 1 every time a prime number is found.

Aim:

Find the most prime numbers in a minute.

Anyone can join the competition, post as many scripts as they want, etc. This competition doesn't have a prize or anything to look forward to except pwning everyone else at prime numbers.

Mine found 6024.

Note: computers which run at different speeds may change score.

Good luck!
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
27 Feb 2012 10:37 AM
[ Content Deleted ]
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
27 Feb 2012 11:09 AM
[ Content Deleted ]
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
27 Feb 2012 11:33 AM
This is myne:

local n = 0
local add = true
local st = tick()
local pn = {2}
local hp = 0
local i = 0
while true do
i = i + 1
add = true
for t = 1, #pn do
if i/pn[t] == math.floor(i/pn[t]) and i ~= pn[t] and pn[t] ~= 1 then
add = false
end
end
if add == true then
n = n + 1
hp = i
pn[#pn+1] = i
add = true
end
if tick() > st+60 then
break
end
end
print("Number of prime numbers found: ",n,". Highest prime found: ",hp,".")

Why ish it so slow?
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
27 Feb 2012 12:21 PM
I got 4 billion in 30 seconds with C++ before, lemme dig up source

FOOL
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
27 Feb 2012 12:22 PM
[ Content Deleted ]
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
27 Feb 2012 01:17 PM
So whai'z myne so slow? I can't see anything wrong with it... -_-
I thought it would actually be good considering it only divides prime numbers, not all numbers, or is it obvious to do that?

Also, post the source too, or I'm not going to believe you. 9000 in less than a second is messed up. Well, compared to mine it is :P
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
27 Feb 2012 01:18 PM
Got mine up to 9000...

still failz D:
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
27 Feb 2012 01:38 PM
Improved mine furtherly,

local add = true
local st = tick()
local pn = {2}
local i = 0
local n = 0
repeat
i = i + 1
add = true
for t = 1, #pn do
if i/pn[t] == math.floor(i/pn[t]) and i ~= pn[t] and pn[t] ~= 1 then
add = false
break
end
end
if add == true then
pn[#pn+1] = i
n = n + 1
end
until(tick() > st+1)
print("\nNumber of prime numbers found: ",n)

This gave me 1000 in 1 second.
I wrote it on my phone :D
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
27 Feb 2012 02:22 PM
Found 19073 in a minute naow.

Anyone else?
Report Abuse
rcm is not online. rcm
Joined: 29 Jul 2008
Total Posts: 621
27 Feb 2012 02:35 PM
19,000 in a minute? Pfft, mine can get 19,000 in 15 seconds:

max = 220000
primes = {}
function IsPrime(num)
for i=1, #primes do
if num%primes[i] == 0 then
return
end
end
return true
end
t = tick()
for i=2, max do
if IsPrime(i) then
table.insert(primes,i)
end
end
print(#primes.." primes found in "..tick()-t.." seconds")
--print(table.concat(primes,", "))
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Feb 2012 05:35 PM
My script can find 302824 primes up to 4300001 in 60 seconds
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Feb 2012 06:00 PM
Update: 374363 primes up to 5400001
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Feb 2012 06:15 PM
Trololol I had a breakthrough and now I've found

928293 primes up to 14300000 is 60 seconds

I WIN!!! so far.
once you surrender, I'll post the program.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
27 Feb 2012 06:17 PM
@xXxMoNkEyMaNxXx

I'm sure I could optimize your code. :P
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
27 Feb 2012 06:30 PM
Anyways, all of these should be ran on the same computer. Otherwise, the results won't be really accurate.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Feb 2012 06:44 PM
I have an Intel i5 2500K @ 3.3 GHz, and also my new best is

1061198 primes up to 16500001

with Julien's help
TROLOLOL WINNING BY DOUBLE
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
27 Feb 2012 06:48 PM
I'm sure I could optimize it more by looking at it thoroughly, though. I just quickly did some simple stuff I knew would make it faster.

Heh, you know that if NecroBumpist decides to participate, we're all dead, right?

Same if Stravant decides to participate.. :/
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Feb 2012 06:52 PM
Idunno, we'll see.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
27 Feb 2012 06:56 PM
Best way to optimize it:

Rewrite it entirely in LASM.
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
27 Feb 2012 07:09 PM
Heh, with a simple C++ program I got 113301 primes... in one second.

When making the integers 64-bit, there was quite a performance decrease: 76549 primes. :O
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Feb 2012 07:16 PM
I can get 113301 primes in 2 seconds (up to 1487873) with Lua :)
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
27 Feb 2012 07:25 PM
[ Content Deleted ]
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
27 Feb 2012 07:26 PM
[ Content Deleted ]
Report Abuse
nightname is not online. nightname
Joined: 10 Jun 2008
Total Posts: 8960
27 Feb 2012 07:26 PM
MY METHOD BRO


primes = {};
time = os.time();
function isPrime(num)
for i = 2, math.sqrt(num) do
if num % i == 0 then
return false
end
end
return true
end

for i = 2, 1000000 do
if isPrime(i) then
table.insert(primes,i);
end
end

endTime = os.time();

print(#primes,endTime-time);
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image