Created
January 22, 2011 14:06
-
-
Save vaclavbohac/791138 to your computer and use it in GitHub Desktop.
Testing program for node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple testing program for node.js. | |
* Prints prime numbers up to 10000. | |
* @author Vaclav Bohac (c) 2011 | |
*/ | |
(function (sys) { | |
var i = 2, | |
isPrime = function () { | |
var j = 2 | |
max = i / 2; | |
while ( j <= max ) { | |
if ( i % j === 0 ) { | |
return false; | |
} | |
j += 1; | |
} | |
return true; | |
}, | |
result = []; | |
sys.puts("Created by <[email protected]>"); | |
while ( i < 10000 ) { | |
if ( isPrime() ) { | |
result.push(i); | |
} | |
i += 1; | |
} | |
sys.puts(result); | |
}(require("sys"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment