Toby

Untitled

Jun 8th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  1. <?php
  2.  
  3. print "PHP\n";
  4.  
  5. $startTime = microtime(true);
  6.  
  7. $result = 0;
  8. for ($i=2; $i<10000; $i++) {
  9.     $prime=true;
  10.     for ($j=2; $j<$i; $j++) {
  11.         if ($i%$j==0) {
  12.             $prime=false;
  13.             break;
  14.         }
  15.     }
  16.     if($prime)
  17.         $result++;
  18. }
  19.  
  20. print $result."\n";
  21. print (microtime(true)-$startTime)." s\n\n";
  22.  
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment