Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2011
1,465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2. $start_time=time();
  3.  
  4. $x=array(2);
  5. $n=200000;
  6. for($i=3; $i<$n; $i=$i+2)
  7. {
  8.     $simple=true;
  9.     $cnt = count($x);
  10.     for($j=0; $j<$cnt; $j++)
  11.     {
  12.         if($i%$x[$j]==0)
  13.         {
  14.             $simple=false; break;
  15.         }
  16.     }
  17.     if($simple)
  18.     {
  19.         array_push($x,$i);
  20.     }
  21. }
  22. echo("data = ".implode($x, ','));
  23.  
  24. echo('
  25. time = '.(time()-$start_time).' ');
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement