Skip to content

Instantly share code, notes, and snippets.

@iambibhas
Last active December 21, 2015 04:49
Show Gist options
  • Save iambibhas/6252848 to your computer and use it in GitHub Desktop.
Save iambibhas/6252848 to your computer and use it in GitHub Desktop.
Checks if the given number is prime
import sys
import math
def is_prime(number):
if number <= 1:
return False
if number == 2:
return True
if number % 2 == 0:
return False
for current in range(3, int(math.sqrt(number) + 1), 2):
if number % current == 0:
print "Divisible by ", current
return False
return True
if __name__ == "__main__":
if len(sys.argv) >= 2:
print is_prime(int(sys.argv[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment