Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions allalgorithms/numeric/isPrime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: UTF-8 -*-
#
# Check if is prime
# The All ▲lgorithms library for python
#
# Contributed by: Natan Lucena
# Github: @NatanLucena
#

def isPrime(n) :

if (n <= 1) :
return False
if (n <= 3) :
return True

if (n % 2 == 0 or n % 3 == 0) :
return False

i = 5
while(i * i <= n) :
if (n % i == 0 or n % (i + 2) == 0) :
return False
i = i + 6

return True