n = int(input("Escribe un número: "))

if n < 0:
    print("No se permiten números negativos")
else:
    c = 0

    for x in range(1, n + 1):
        if n % x == 0:
            c += 1

    if c == 2:
        print("El número es primo")
    else:
        print("El número no es primo")

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: