示例#1
0
def pe21(limit=10000):
    """
    >>> pe21()
    (31626, [(220, 284), (1184, 1210), (2620, 2924), (5020, 5564), (6232, 6368)])
    """
    ami = []
    s = 0
    for i in range(2, limit + 1):
        t = spd(i)
        if i < t and i == spd(t):
            s += i + t
            ami.append((i, t))
    return (s, ami)
示例#2
0
文件: pe21.py 项目: kittttttan/pe
def pe21(limit=10000):
    """
    >>> pe21()
    (31626, [(220, 284), (1184, 1210), (2620, 2924), (5020, 5564), (6232, 6368)])
    """
    ami = []
    s = 0
    for i in range(2, limit + 1):
        t = spd(i)
        if i < t and i == spd(t):
            s += i + t
            ami.append((i, t))
    return (s, ami)
示例#3
0
def pe23(limit=28123):
    """
    >>> pe23()
    4179871
    """
    s = 0
    abn = set()
    for n in range(1, limit):
        if spd(n) > n:
            abn.add(n)
        if not any((n - a in abn) for a in abn):
            s += n
    return s