Skip to content

Instantly share code, notes, and snippets.

@vaclavbohac
Created January 22, 2011 14:06
Show Gist options
  • Save vaclavbohac/791138 to your computer and use it in GitHub Desktop.
Save vaclavbohac/791138 to your computer and use it in GitHub Desktop.
Testing program for node.js
/**
* 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