/ Published in: PHP
List of prime numbers between two number
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Softafzar.Net | Developers home_ * http://softafzar.net */ $num1 = 2; $num2 = 200; $col = 0; echo "<h1>List of prime numbers from $num1 to $num2 </h1>"; echo '<table width="60%" border="1"><tr>'; foreach ( Prime ( $num1, $num2 ) as $item ) { if ($col >= 10) { echo '</tr><tr>'; $col = 0; } echo "<td> $item </td>"; $col ++; } echo '</tr></table>'; function Prime($num1, $num2) { while ( $num1 < $num2 ) { $isprime=true; if ($num1 % $i == 0) $isprime=false; } if ( $isprime ) { $prime_numbers [] = $num1; } $num1 ++; } return $prime_numbers; } ?>
URL: http://www.softafzar.net/thread1575.html/