### Which powers of 2 do not contain the digit 7?

Which powers of 2 do not contain the digit 7? A quick search reveals the following examples.

2^0 = 1 2^1 = 2 2^2 = 4 2^3 = 8 2^4 = 16 2^5 = 32 2^6 = 64 2^7 = 128 2^8 = 256 2^9 = 512 2^10 = 1024 2^11 = 2048 2^12 = 4096 2^13 = 8192 2^14 = 16384 2^16 = 65536 2^18 = 262144 2^19 = 524288 2^22 = 4194304 2^23 = 8388608 2^25 = 33554432 2^28 = 268435456 2^33 = 8589934592 2^41 = 2199023255552 2^42 = 4398046511104 2^49 = 562949953421312 2^50 = 1125899906842624 2^54 = 18014398509481984 2^61 = 2305843009213693952 2^71 = 2361183241434822606848

These exponents are listed in the On-line Encyclopedia of Integer Sequences as A035062.

I have continued the search for exponents up to 10^{10}, and found no other powers of 2 that do not contain the digit 7. If we suppose that the decimal digits of powers of 2 are random, then it is extremely unlikely that other examples exist. Observe that *2 ^{n}* has approximately decimal digits, so the probability that

*2*does not contain the digit 7 is approximately

^{n}*r*where

^{n}Given that no examples exist for , we can estimate the probability of an additional example via the infinite sum

This probability is so small that it almost defies comprehension. Imagine that every person in the State of New York picked a random combination for the Powerball lottery, that they all picked the same numbers purely by chance, and they all won the jackpot. Absurd as it is, this event is more probable than finding another power of 2 which does not contain the digit 7, unless there is some hidden pattern in the digits which has escaped our attention.

I wrote a Python program to conduct my search. Since powers of 2 grow very rapidly, it is not efficient to generate all of their digits, so I only kept track of the last 70 digits. If a 7 is not found in the last 70 digits, then the last 400 digits are checked using the three-argument *pow* function. If a 7 is not found in the last 400 digits, then *n* is printed, but no further checks are made. Here is my code:

n = 0 N = 1 while 1: if not('7' in str(N)) and not('7' in str(pow(2, n, 10**400))): print "2^" + str(n) n += 1 N = (N * 2) % 10**70

My interest in this question was inspired by a blog post by John D. Cook.