Prime number algorithm