def check_condition(num):
    t = prime_utils.totient(num)
    return num * 1.0 / t if sorted(str(num)) == sorted(str(t)) else -1
'''
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 totient_chain_length( n ):
    if n in range( 21 ): return ( 1, 1, 2, 3, 3, 4, 3, 4, 4, 4, 4, 5, 4, 5, 4, 5, 5, 6, 4, 5, 5 )[n]
    return 1 + totient_chain_length( totient( n ) )