Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / Prime Number Generator

Author
Message
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 4th Jun 2008 00:23
Application is attached.

This is a very cool (if you are just that little bit nerdy) application that generates prime numbers, utilizing the power of all the cores that you have on your computer (up to 10).

-Start Number: enter the number that you want to begin searching for primes at.
-End Number: enter the number that you want to stop searching for primes at.
-Number of cores: enter the number of cores on your computer for optimum performance. e.g. if you have a core 2 processor, enter 2. Note that you can have a number greater or less than the number of cores on your computer; processor usage will be shared between each thread but performance will be hampered.

At the end, the amount of time it took to complete the search in milliseconds (1000ms in 1second) is displayed. This could be used if you wanted to run a performance comparison between multiple computers.

The order in which numbers are displayed is roughly from lowest to highest. If you specify more than one core they will not be in exact numerical order.

CPP code:


Screenshot:

Attachments

Login to view attachments
Jeff032
16
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 4th Jun 2008 16:34
This may get locked because it's not made with a TGC product, but you could maybe make it faster when checking whether a large number is prime by changing the loop to something like

for (int n = 2; n <= (int)sqrt(iCurrentNo); n++)

On a calculator, the speed gain is considerable, on a computer, maybe not so much (I'm not sure), but no point in doing extra work.

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 6th Jun 2008 06:52 Edited at: 6th Jun 2008 06:55
Cool.

It started spazzing out after around 2500 or so.

If you can do any models for FW, reply to the FleetWars thread.

Click here!
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 6th Jun 2008 11:45
One limitation is that the maximum number it can cope with is roughly: 2147483647 due to the nature of CPP integers. Weird things happen above this number such as displaying lots of negative numbers or not doing anything at all.

If it never got to numbers this high then could you post a screenshot please
Alsan
18
Years of Service
User Offline
Joined: 20th May 2005
Location: Germany - Nähe Kassel
Posted: 7th Jun 2008 21:07
Hiho,

Thanks for this program . I used it as a small benchmark today when I got my new processor.

My old AMD 3700+ needed roughly 100 seconds to find all numbers from 0 to 300.000, the new Intel Q6700 does it in about 12 seconds. Quite an improvement. ^^

Login to post a reply

Server time is: 2024-04-25 09:38:28
Your offset time is: 2024-04-25 09:38:28