Usuario:Diana~eswikibooks/ejercicio 13
Apariencia
- Determinar si un numero es primo
- Propósito: Averiguar si un número es primo
from math import sqrt
print 'VER SI UN NÚMERO ES PRIMO\n'
numero= int(raw_input('Dame un entero mayor que cero: '))
- Determinar si el número es primo
es_primo= True for divisor in range(2, int(sqrt(numero))+1):
if numero%divisor==0: es_primo= False break # Interrumpe la ejecución del bucle
if es_primo:
print '%d es primo' % numero
else:
print '%d no es primo' % numero