Javascript. Finds the nth prime number