Sunday, 14 October 2007

nt.number theory - 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 2, and two are by Banks and Shparlinski (one also with Conflitti) 3 4. Presumably some of these authors can say whether the problem should be called open.

No comments:

Post a Comment