Today's Question:  What weekend projects have you created?

### Generate first N prime numbers

Recently I am taking an online course named "Startup Engineering" on coursera. There is one assignment which is to use NodeJS to write a program to generate the first 100 prime numbers. This may be very easy for many people. Here I just want to share with you the code to generate not only the first 100 prime numbers. but also any number of prime numbers. Below is the code snippet: //Helper class to generate prime numbers var PrimeProcessor=(function(){ var primeArray=[]; functio...

### A Perl Regular Expression That Matches Prime Numbers

perl -lne '(1x\$_) =~ /^1?\$|^(11+?)\1+\$/ || print "\$_ is prime"' Can you figure out how it works? I give an explanation below, but try to figure it out yourself. Here is what happens when you run it: \$ perl -lne '(1x\$_) =~ /^1?\$|^(11+?)\1+\$/ || print "\$_ is prime"' 1 2 2 is prime 3 3 is prime 4 5 5 is prime 6 7 7 is prime 8 9 10 11 11 is prime Here is how it works. First, the number is converted in its unary representation by (1x\$_). For example, the number 5 gets converted into 1x5, which is ...