A JavaScript algorithm to find prime numbers