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
def product(self): return reduce_product(self)
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
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)
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