In [1]:
def is_prime(n):
    '''Return True iff n is prime
    Arguments:
    n -- a  non-negative integer
    '''
    
    #Take care of the special cases first
    if n <= 1:
        return False
    
    if n == 2:        #optional
        return True
    
    
    #Try to compute the remainder of the division of n by (i+2)
    #for i = 0, 1, 2, ..., n-3
    #If the remainder is 0, return straight away
    for i in range(n-2):
        if n % (2+i) == 0:  #n=121, i = 9: n % (9+2) == 0
            return False
    
    #If we are here, that means that we never returned False, so we tried
    #all the possible factors and it turned out that 
    return True