note 46650 deleted from ref.math by sean
| From: | sean@php.net | Date: | Tue, 19 Oct 2004 13:52:16 +0000 |
| Subject: | note 46650 deleted from ref.math by sean | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78754@lists.php.net to get a copy of this message | ||
Note Submitter: christian dot leo at aon dot at
----
here's a little function i wrote recently to get all primes between 3 and a value you'd
like:
<?php
function prime($i)
{
$n = 3;
while($n <= $i)
{
$count = 0;
$m = 2;
while($m < $n)
{
$r = $n % $m;
if($r == 0)
{
$count++;
$m++;
}
if($r != 0)
{
$m++;
}
}
if($count == 0) //must be a prime
{
echo $n."<br>";
}
$n++;
}
}
?>
----
Reason: useless example