示例#1
0
def p009():
    """
    for each possible pythagorean triplet:
        if 1000 is divisible by the sum of the triplet:
            RETURN: multiply product and the multiplier cubed
    """
    for tri in pytriple_gen(int(1000 // 2)):
        if 1000 % sum(tri) == 0:
            return reduce_product(tri) * (1000 // sum(tri))**3
示例#2
0
文件: maths.py 项目: saetar/pyEuler
 def product(self):
     return reduce_product(self)
示例#3
0
文件: maths.py 项目: saetar/pyEuler
def repermutations(toop):
    c = Counter(n for n in toop)
    a = list(factorial(nc) for nc in c.values())
    ans = factorial(len(toop)) // reduce_product(a)
    return ans
示例#4
0
            t += 1
    if t > 3:
        print(i, t)
        n += 1

print(n)

def powers_lt(n, lim):
    i = n
    while i <= lim:
        yield i
        i *= n



d = {}
s = set()
for p in lt100:
    print(list(powers_lt(p, 1000)))
    s.update(set(powers_lt(p, 1000)))
t = len(s)
for rrr in range(2, 4):
    for c in combinations(s, r=rrr):
        if (reduce_product(c)) < 1000: t += 1
print(t)

# t = 1
# while(t<10**16):
#     t*=2
#     print(t)
示例#5
0
def p033():
    fracs = {Fraction(n, d) for d in range(11, 100) for n in range(10, d) if is_fishy_fraction(n, d)}
    return reduce_product(fracs).denominator