There are many ways to create a prime numbers. However, the time constraints will reflect your skill to create an algorithm. Whereas I am a student of computer science, the algorithm should meet time efficiency. I am sure that all of you already had project about prime numbers. In the following examples, I will be using the Python2.5 programming language to demonstrate such algorithms and compare their efficiencies. Later I will also update it into C/C++ and Java languages.
The first algorithm we shall consider will begin with the integer 2 and proceed to select each successive integer as a potential prime, (pp), checking for primacy by testing to see if it can be factored by any previously identified primes, then storing each newly verified prime in a prime set (ps) array.

Leave a comment
Comments feed for this article