Skip to content

Instantly share code, notes, and snippets.

@pdbartsch
Created February 7, 2019 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdbartsch/679ea6e03de00114922e4cb45cb4be1a to your computer and use it in GitHub Desktop.
Save pdbartsch/679ea6e03de00114922e4cb45cb4be1a to your computer and use it in GitHub Desktop.
invar = int(input("Please enter an integer to find out whether it's prime or not: "))
def prime(n):
divisors = [ x for x in range(1,n+1) if n % x == 0]
if len(divisors) == 2:
print('prime')
else:
print('not prime')
prime(invar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment