Skip to content

Instantly share code, notes, and snippets.

@gaspart
Last active November 20, 2019 11:04
Show Gist options
  • Save gaspart/8295b12cfed7a7910a044e4475b90899 to your computer and use it in GitHub Desktop.
Save gaspart/8295b12cfed7a7910a044e4475b90899 to your computer and use it in GitHub Desktop.
very simple code to check if a number is prime
import sys
i = 2
numero = int(input("Dimmi un numero, e ti dirò se è un NUMERO PRIMO: "))
print()
while i < numero:
if numero % i == 0:
print(str(numero) + " è divisibile per " + str(i))
sys.exit()
i += 1
next
print(str(numero) + " è primo")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment