dkoug Blog

Basic prime number check

Python -- Posted on Aug. 23, 2017

Basic prime number check in python

1
2
3
4
5
6
7
8
9
def is_prime(n):
    '''
    Check prime number
    '''
    if n == 2 or n == 3:
        return True
    if n % 2 == 0 or n % 3:
        return False
    return True