prime check by finding smallest divisor recursively in swift