bestPerm n = fst $ minimumBy (compare `on` phiRatio) $ totientPerms n
    where phiRatio (x,p) = fromIntegral x / fromIntegral p
bestPerm n = fst $ minimumBy (compare `on` phiRatio) $ totientPerms n
    where phiRatio (x,p) = fromIntegral x / fromIntegral p
bestPerm n = fst $ minimumBy (compare `on` phiRatio) $ totientPerms n
    where phiRatio (x,p) = fromIntegral x / fromIntegral p