Toby

Untitled

Jun 8th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. console.log("Javascript, NodeJS");
  2.  
  3. var startDate = new Date();
  4.  
  5. var result = 0;
  6. for (i=2; i<10000; i++) {
  7.     var prime=true;
  8.     for (j=2; j<i; j++) {
  9.         if (i%j==0) {
  10.             prime=false;
  11.             break;
  12.         }
  13.     }
  14.     if(prime)
  15.         result++;
  16. }
  17.  
  18. console.log(result);
  19. console.log(((new Date().getTime() - startDate.getTime())/1000)+" s");
  20. console.log("");
Advertisement
Add Comment
Please, Sign In to add comment