updated algorithm

previous version checked all odd numbers, that is not Sieve of
Eratosthenes