Пример #1
0
def main2():
    semiprimes = create_semiprimes()
    numbers = set() # totient(n) is a permutation of n
    min_value = 100
    min_n = 0
    for semiprime in semiprimes:
        if is_perm(semiprime, totient(semiprime)):
            numbers.add(semiprime)
            
    for num in numbers:
        tmp = num / float(totient(num))
        if tmp < min_value:
            min_value = tmp
            min_n = num
    print min_n
Пример #2
0
def main2():
    max_value = 0
    max_n = 0
    for n in xrange(1, 1000001):
        value = n / float(totient(n))
        if max_value < value:
            max_value = value
            max_n = n
    print max_n
Пример #3
0
def main1():
    """This aproach is very slow."""
    end = 10 ** 7
    lowerbound = 2000
    upperbound = 5000
    numbers = list() # totient(n) is a permutation of n
    for i in xrange(2, end):
        if is_perm(i, totient(i)):
            numbers.append(i)
    print len(numbers)
Пример #4
0
def main():
    max_d = 10 ** 6
    print sum([totient(x) for x in range(1, max_d+1)]) - 1