¿Cuál es el equivalente de Python del bucle estándar de Java?
Estoy escribiendo un algoritmo simple para verificar la primalidad de un número entero y tengo un problema al traducir este código Java a Python:
for (int i = 3; i < Math.sqrt(n); i += 2) {
if (n % i == 0)
return false;
}
Entonces, he estado tratando de usar esto, pero obviamente estoy saltando la división por 3:
i = 3
while (i < int(math.sqrt(n))):
i += 2 # where do I put this?
if (n % i == 0):
return False