Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ Program to find prime numbers [ FINISHED ! ]
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Fri Dec 17, 2010 12:39 pm    Post subject: Reply with quote

Flyte wrote:
Bitches don't know 'bout template meta-programming.

Constant time, yo.

wow
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sat Dec 18, 2010 10:58 am    Post subject: Reply with quote

Wiccaan wrote:
HomerSexual wrote:

Code:
   // Initialize pos 0, 1 to false.
   primeCache.set( 0, false );
   primeCache.set( 1, false );


I'm confused by these lines


Not sure if you are confused by the code itself or my wording of it. By saying pos 0, 1 I didn't mean like a graph or anything, meant 0 and 1 are both not prime so their positions inside the bit array are set to false manually.

Not setting 0 manually will cause the first loops test to succeed when x = 0, turning the second loop into an infinite loop due to the stepping.
y += x will never properly step if x is 0 so it will never continue.

Not setting 1 manually will cause the full array to set to false. Instead of stepping the proper x * x + y which should multiply forward it steps every number because x = 1, so you land up with y = x * x, y += x, 1 * 1 + 1 = 2, 2 + 1 = 3, 3 + 1 etc. so it will end up stepping every number in the bitset.

(This is not including the theory that 0 is/isn't prime and/or is/isn't a number and all that fun jazz.)


oh my bad totally misread the code, my apologies. That's embarrassing >.<

_________________
Back to top
View user's profile Send private message
sangeli
Master Cheater
Reputation: 0

Joined: 07 Dec 2006
Posts: 406

PostPosted: Sat Dec 18, 2010 4:17 pm    Post subject: Reply with quote

Slugsnack wrote:
educofu wrote:
sangeli wrote:
I didn't read into the other posts very much but remember that you only need to count up to the square root of the number to look for multiples. should save time.


didnt work. but counting up to the half of the number does.

You don't need to count up to half. Counting up to the ceiling of the square root will do.

mhmm

_________________
Dark Byte wrote:
ce can certainly damage hardware let's say you have a robotarm attached to your computer, and the software limits usually block it from ripping out it's own cpu. If you remove that limit and then issue the command to rip out the cpu, sure, say goodbye to your hardware
Back to top
View user's profile Send private message
Jorg hi
I post too much
Reputation: 7

Joined: 24 Dec 2007
Posts: 2276
Location: Minnesota

PostPosted: Sat Dec 18, 2010 4:40 pm    Post subject: Reply with quote

0 isn't a prime number xD it can be divided by 0. Zero should be a special prime number in my opinion.
_________________
CEF will always stay alive.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites