def A( n ):
    if is_probable_prime( n ) or gcd( n, 10 ) != 1: return None

    r, k = 11111, 5
    while True:
        if not r % n: break

        r = r * 10 + 1
        k += 1

    return k
def primedSpiral():
    '''
        Returns the side length of the first spiral for which the number of primes along the diagonals are less than 10%
    '''
    primes_count, n = 0, 2
    while( True ):
        length = ( n << 1 ) - 1
        sq = length ** 2
        for i in xrange( 0, ( n - 1 ) << 3, ( n - 1 ) << 1 ):
            if is_probable_prime( sq - i ): primes_count += 1

        if primes_count * 10 < ( ( length << 1 ) + 1 ): return length
        n += 1
def getSmallestPrime():
    for num in range( 11, 1000, 2 ):
        if num % 5 == 0: continue

        numDigits = getDigitsIn(num)
        for pattern in getPattern5() if num < 100 else getPattern6():
            numbers = generateNumbers( pattern, numDigits )
            
            size = len( numbers )
            for number in numbers:
                if not is_probable_prime( number ):
                    size -= 1
                    if size < 8: break

            if size == 8:
                return numbers[0]
'''
Created on Jul 27, 2012

@author: anuvrat
'''
from utils.prime_utils import totient, is_probable_prime

max_ratio, max_number = 0.0, 0
for n in xrange( 1, 10 ** 6, 1 ):
    if is_probable_prime( n ): continue
    ratio = n * 1.0 / totient( n )
    if ratio > max_ratio:
        max_ratio = ratio
        max_number = n

print max_number
def can_be_written( odd_composite ):
    for square in squares:
        if is_probable_prime( odd_composite - square ): return True
'''
Created on Jun 30, 2012

@author: anuvrat
'''
from utils.prime_utils import is_probable_prime

squares = [2 * x * x for x in range( 1, 1000000 )]

def can_be_written( odd_composite ):
    for square in squares:
        if is_probable_prime( odd_composite - square ): return True

for odd_composite in xrange( 9, 10 ** 9, 2 ):
    if not is_probable_prime( odd_composite ) and not can_be_written( odd_composite ): break

print odd_composite