fix algorithm that checks prime number