FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Search found 2 matches
Forum Index
Author Message
  Topic: bool isPrime(uint n)
Nick

Replies: 5
Views: 25325

PostForum: Deimos   Posted: Tue Aug 03, 2004 2:41 pm   Subject: bool isPrime(uint n)
Oh and I found a few trivial bugs. First, you store the current divider in q[i] for use later, but then overwrite it with the bool indicating if it is a prime. Second, in the first block in the loop, ...
  Topic: bool isPrime(uint n)
Nick

Replies: 5
Views: 25325

PostForum: Deimos   Posted: Tue Aug 03, 2004 1:38 pm   Subject: bool isPrime(uint n)
Looks very good! Personally think it could need some comenting, though...

Also, you should replace

r = n / q;
if ( n == r * q ) return false;

with

if ( n ? q == 0 ) return ...
 
Page 1 of 1
All times are GMT - 6 Hours
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group