View Single Post
Old 05-31-2009, 07:33 PM   PM User | #1
Relish
New Coder

 
Join Date: May 2009
Location: Cincinnati
Posts: 45
Thanks: 0
Thanked 4 Times in 4 Posts
Relish is an unknown quantity at this point
PHP Prime Number Generator

Not sure how useful this is, but interesting. It will output all the prime numbers between the inputted start and end numbers.

PHP Code:
<form action="#" method="get">
  <input name="start" type="text"  />
  <input name="end" type="text" />
  <input name="submit" type="submit" value="Go!" />
</form>
 
<?php
  
for ($i $_GET['start']; $i <= $_GET['end']; $i++)
  {
    if(
$i != 1) continue;
    
$d 3;
    
$x sqrt($i);
    while (
$i $d != && $d $x$d += 2;
    if(((
$i $d == && $i != $d) * 1) == 0) echo $i.' ';
  }
?>
Relish is offline   Reply With Quote