def totient_perms(limit): for num in xrange(2, limit): totient_val = totient(num) if sorted(str(num)) == sorted(str(totient_val)): yield num, totient_val
def is_totient_perm(num): return sorted(str(num)) == sorted(str(totient(num)))
def using_totient(): """First attempt - summing the Euler totient of each number ≤ 1,000,000""" s = 0 for n in xrange(LIMIT, 1, -1): s += totient(n) return s