Location: PHPKode > scripts > Prime > prime/math-class.php
<?php
#	Author: Wan-Leong Jiangti
#	Date: 16 October 2003
#	Description: Takes a number and check if it is a prime
#	number, returns boolean value.
	class prime{
		var $number;
		function prime($number){
			$this->number = $number;
		}
		function is_prime(){
			$limit = round(sqrt($this->number));
			$counter = 2;
			while ($counter <= $limit){
					if($this->number % $counter == 0){
						return true;
					}
				$counter ++;
			}
			return false;
		}
	}
?>
Return current item: Prime