Created
August 2, 2015 12:03
-
-
Save viveksyngh/95ec1ccbabc271cb250b to your computer and use it in GitHub Desktop.
Check for prime
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
__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