News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Klaus Graefensteiner's Blog:
Two ways to test for prime numbers in PHP Sieve and File
February 26, 2010 @ 13:33:43

In a new post to his blog Klaus Graefensteiner takes a look at two ways to test for prime numbers both with Sieve and from a file.

In PHP is really no ideal way to test large integers and determine whether they are prime numbers or not. The most popular algorithm for finding prime numbers is a memory and resource hog. It is called The Sieve of Eratosthenes.

You can get more of an idea on this method in this video and in this example from Wikipedia. He includes the full source for his solution that includes methods like isInteger, isPositive, isPerfectSquare and isPalindromicPrime. The script is also available for download.

0 comments voice your opinion now!
prime number tutorial sieve


blog comments powered by Disqus

Similar Posts

PHPBuilder.com: PHPUnit Fundamentals: Setting Up and Tearing Down a Doctrine 2 Database

Jeremy Cook's Blog: Normalising DateTimes with Doctrine Events

The Bakery: 11 New Posts of CakePHP Goodness

Michael Nitschinger's Blog: Handling JSON like a boss in PHP

Adam Lundrigan: Quick-and-dirty ZF2: Zend\Navigation


Community Events











Don't see your event here?
Let us know!


opinion hack component release language code hhvm podcast overview framework application security install package symfony2 example facebook introduction unittest composer

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework