Ejemplo n.º 1
0
def p46():
    #getting precalculated primes and squares:
    u = Utils()
    primes = u.sieve(6000)
    squares = [i * i for i in range(1, 101)]
    #start searching at 15:
    o = 15
    while o < 5800:
        #is the test number prime?
        if u.chop(o, primes) != -1:
            #yeap, go to next one:
            o += 2
            continue
        #nope, begin testing:
        ind = 0
        found = False
        while o - primes[ind] > 0:
            s = (o - primes[ind]) / 2
            #found desired decomposition?
            if u.chop(s, squares) != -1:
                #yep, break out:
                found = True
                break
            #nope, try next prime:
            else:
                ind += 1
            #found possible candidate:
        if not found:
            return o
        #keep searching:
        o += 2
Ejemplo n.º 2
0
def p44():
    u = Utils()
    limit = 3000
    pl = [f.p(i) for i in range(limit)]
    for a in range(1, limit):
        for b in range(1, limit):
            if a > b:
                c = pl[a] + pl[b]
                d = pl[a] - pl[b]
                if u.chop(c, pl) > -1 and u.chop(d, pl) > -1:
                    print(a, b, pl[a], pl[b], pl[pl.index(c)], pl.index(c),
                          pl[pl.index(d)], pl.index(d))
Ejemplo n.º 3
0
def p44():
    u = Utils()
    limit = 3000
    pl = [f.p(i) for i in range(limit)]
    for a in range(1, limit):
        for b in range(1, limit):
            if a > b:
                c = pl[a] + pl[b]
                d = pl[a] - pl[b]
                if u.chop(c, pl) > -1 and u.chop(d, pl) > -1:
                    print(a, b, pl[a], pl[b],
                        pl[pl.index(c)],
                        pl.index(c),
                        pl[pl.index(d)],
                        pl.index(d))
Ejemplo n.º 4
0
def all_in(l1, l2, u):
    u = Utils()
    for n in l1:
        if u.chop(n, l2) == -1:
            return False
    return True