Click here to Skip to main content
15,899,313 members
Articles / Programming Languages / C

Quicker Prime Number Test

Rate me:
Please Sign up or sign in to vote.
4.88/5 (5 votes)
6 Nov 2011CPOL 9.4K   33  
When you search manually, you can search for every odd number that is a step of 2. If you're a bit more clever (as you are), you can use steps of 6 (2 * 3). Testing (testno+1)%6==0 is very similar to (testno % 6) = 5.You can speed up big time by having a loop that increments per steps of...

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
France France
I am a French programmer.
These days I spend most of my time with the .NET framework, JavaScript and html.

Comments and Discussions