# 932718654 import euler N = 9 m = 0 for a in xrange(1, 10 ** (N/2)): n = 0 s = '' while len(s) < N: n += 1 s += str(a * n) if len(s) == N and euler.digit_usage(int(s)) == int('1' * 9 + '0', 2): if int(s) > m: m = int(s) print m
# 100 import math import euler D = 2 N = 10 ** D np = 1 dp = 1 for n in xrange(N/10, N): for d in xrange(n+1, N): nn = euler.digit_usage(n) dd = euler.digit_usage(d) c = nn & dd if c == 0 or c == 1 or math.log(c, 2) % 1.0 != 0 or \ nn ^ c == 0 or dd ^ c == 0: continue n2 = math.log(nn ^ c, 2) d2 = math.log(dd ^ c, 2) if d2 != 0 and float(n) / d == n2 / d2: np *= n dp *= d np, dp = euler.reduce_fraction(np, dp) print dp
# 45228 import euler p = {} for a in xrange(1, 10000): for b in xrange(a+1, 10000 / a + 1): c = a * b aa = euler.digit_usage(a) bb = euler.digit_usage(b) cc = euler.digit_usage(c) if aa & bb & cc == 0 and aa | bb | cc == int('1111111110', 2): p[c] = True print sum(p.keys())
# 142857 import euler N = 6 d = 1 while True: for n in range(10 ** d, 2 * 10 ** d): found = True nn = euler.digit_usage(n) for i in range(2, N + 1): if nn != euler.digit_usage(n * i): found = False break if found: print n break if found: break d += 1
# 296962999629 import euler D = 4 N = 10 ** D S = 3330 sieve = euler.prime_sieve(N) for a in xrange(N/10+1, N, 2): b = a + S c = b + S if a != 1487 and sieve[a] and sieve[b] and sieve[c]: aa = euler.digit_usage(a) if aa == euler.digit_usage(b) and aa == euler.digit_usage(c): print '%d%d%d' % (a, b, c) break
# 16695334890 import math import euler s = 0 for a in xrange(1, 999/17): aa = euler.digit_usage(a * 17, 3) for b in xrange(1, 999/13): if (a * 17) / 10 != (b * 13) % 100: continue for c in xrange(1, 999/11): if (b * 13) / 10 != (c * 11) % 100: continue for d in xrange(1, 999/7): if (c * 11) / 10 != (d * 7) % 100: continue dd = euler.digit_usage(d * 7, 3) if aa & dd != 0: continue for e in xrange(1, 999/5): if (d * 7) / 10 != (e * 5) % 100: continue for f in xrange(1, 999/3): if (e * 5) / 10 != (f * 3) % 100: continue for g in xrange(999/2): if (f * 3) / 10 != (g * 2) % 100: continue gg = euler.digit_usage(g * 2, 3) if aa & gg != 0 or dd & gg != 0: continue