Created
April 7, 2019 03:08
-
-
Save FrancoMuniz/a383dab373ce3d528c4a932f770e4676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def main(): | |
while True: | |
print(isPrime(int(input('Enter a number to check if it is prime: ')))) | |
def isPrime(n): | |
ans = [num for num in range(2,int(math.sqrt(n)+1)) if n % num == 0] | |
return not bool(ans) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment