Skip to content

Instantly share code, notes, and snippets.

@viveksyngh
Created August 2, 2015 12:03
Show Gist options
  • Save viveksyngh/95ec1ccbabc271cb250b to your computer and use it in GitHub Desktop.
Save viveksyngh/95ec1ccbabc271cb250b to your computer and use it in GitHub Desktop.
Check for prime
__author__ = 'Vivek'
def isPrime(A):
"""
:param: An integer
:return: Returns integer True if it's prime otherwise false
"""
if A == 1:
return False
for i in range(2, int(A ** 0.5) + 1) :
if A%i == 0 :
return False
return True
print(isPrime(1)) #Returns False
print(isPrime(2)) #Returns True
print(isPrime(5)) #Returns True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment