Skip to content

Commit

Permalink
Merge pull request #142 from elaineakemi/master
Browse files Browse the repository at this point in the history
Added Python example for is_prime
  • Loading branch information
gugahoa authored Oct 7, 2019
2 parents 40a4496 + 19c5600 commit 803fbde
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions math/is_prime/python/is_prime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import math

def is_prime(number):
if number <= 1: return False
if number == 2: return True
if (number % 2) == 0: return False

for i in range(3, int(math.sqrt(number)) +1,2):
if number % 1 == 0: return False
return True

number = input ("Enter number :")
if is_prime(number):
print("It is prime")
else:
print("It is not prime")


0 comments on commit 803fbde

Please sign in to comment.