[Pablo Solis](http://math.berkeley.edu/~pablo/) asked this at a recent [20 questions seminar](http://scratchpad.wikia.com/wiki/20qs) at Berkeley. Is there a positive integer $N$, not of the form $10^k$, such that the digits of $N^2$ are all 0's and 1's?


It seems very unlikely, but I don't have a proof. It's easy to see that such a number must end in 1 or 9, and then easy to see that it must end in 01, 49, 51 or 99, and you can continue recursively for as long as you like, determining possible "suffixes". Using this, I had a computer check for me that there are no such N up to about $10^{24}$.


If you pretend that the digits of $N^2$ are randomly distributed, and $N$ has $n$-digits, there's a $(2/10)^{2n}$ chance of satisfying this condition. There are only $10^n$ $n$-digit numbers, so you might expect a $(4/10)^n$ chance of having a some $n$-digit number. This suggests we shouldn't expect to find anything.


(If you try the same problem in other bases, where the probabilities are better, you do find a few: in base 5, 222112144, 22222111221444 and 100024441003001 work.)



Can $N^2$ have only digits 0 and 1, other than $N=10^k$?
In the interest of completeness, here is what I put on the 20-questions wiki — we might as well repeat it here in the $\infty$-questions site. I had basically the same idea as Ilya, do a branched search to look for the digits of $N^2$. However, the code that I wrote in Python works from the 10-adic end, while Ilya's works from the Archimedean end. Both programs support a heuristic model that implies that solutions in the integers are very unlikely. If you wanted an optimized search in the integers, you would work from both ends and try to match the partial solutions. And you would probably want to implement the algorithms in C++ rather than in Python.



```
maxmod = 10**24

def check(x):
    if not str(x**2).replace('0','').replace('1',''):
        print 'Eureka:',x,x**2

def search(x,mod):
    x %= mod
    if mod == maxmod:
        check(x)
        check(mod-x)
        return
    top = -(x**2/mod) % 10
    x += (top + top%2)/2 * mod
    search(x,mod*10)
    search(x + 5*mod,mod*10)

search(1,10)    # Solution is either 1 or 9 mod 10

```

Also, it's tempting to mark the problem as open rather than as a "puzzle". I did find several papers that analyzed the congruence structure of integers with restricted digits, and one that looked at prime factors. Two are by Erdos, Mauduit, and Sarkozy [1](http://dx.doi.org/10.1006/jnth.1998.2229) [2](http://dx.doi.org/10.1016/S0012-365X%2898%2900331-8), and two are by Banks and Shparlinski (one also with Conflitti) [3](http://www.math.missouri.edu/~bbanks/papers/char_sums_restr_digits.pdf) [4](http://www.math.missouri.edu/~bbanks/papers/arith_props_restr_digits.pdf). Presumably some of these authors can say whether the problem should be called open.


