#1




What's the algorithm to determine prime numbers?Hi there,
COuld any one please give me the algorithm to determine weather a number is a "prime" or not? 

#2




Re: Whats the algorithem to determine prime numbers?Quote:

#3




Re: Whats the algorithem to determine prime numbers?A prime number is one that cannot be evenly divided by any number besides 1 and itself so:
CPP / C++ / C Code:

#4




Re: Whats the algorithem to determine prime numbers?Quote:
Nowadays, the smallest prime integer is considered to be 2, although over the years some people have considered 1 to be a prime integer. (Zero has never been considered to be a prime integer under any definition that I have ever seen.) From http://en.wikipedia.org/wiki/Prime_number "In mathematics, a prime number (or a prime) is a natural number greater than 1 which has exactly two distinct natural number divisors: 1 and itself." There's a little redundancy in that definition to emphasize that 1 is not a prime. (After all, if they just said, "a natural number that has exactly two distinct natural number divisors," wouldn't that be sufficient?) Regards, Dave 
#5




Re: Whats the algorithem to determine prime numbers?according to wiki zero is not a prime number:
http://en.wikipedia.org/wiki/Prime_Numbers 
#6




Re: Whats the algorithem to determine prime numbers?oops, i've reposted dave's, sorry

#7




Re: Whats the algorithem to determine prime numbers?Ok, thanks for the info. If we are in agreement that 1 is not prime, you'll have to adjust the function that I gave ever so slightly. Hope it helps you out.

#8




Re: Whats the algorithem to determine prime numbers?Quote:
In the for loop, please explain, why did you devide the num by two and then add a one to it? 
#9




Re: Whats the algorithem to determine prime numbers?Quote:

#10




Re: Whats the algorithem to determine prime numbers?Thanks for all your answers

«
Previous Thread

Next Thread
»
Thread Tools  Search this Thread 
Rate This Thread  



Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
prime numbers  hiflya69  C++ Forum  5  19Oct2007 20:42 
prime numbers help  m3Gigah3rz  C++ Forum  14  06Sep2006 14:00 
Python script: Prime numbers  crystalattice  Python Forum  4  16Apr2006 08:19 
Trouble with the logic of Prime numbers in a certain program.  tylerfelix  C++ Forum  1  02Nov2005 04:15 
Prime Numbers from 0300  Zorachus  C++ Forum  15  12Jul2005 17:33 
Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The
All times are GMT 6. The time now is 05:38.