%I #26 Sep 26 2021 10:08:43
%S 0,1,4,9,121,676,12321,1234321,123454321,12345654321,1234567654321,
%T 123456787654321,12345678987654321
%N Squares whose consecutive digits differ by 1.
%C a(14), if it exists, is > 10^34. - _Lars Blomberg_, Nov 25 2016
%C Is it true that all terms are palindromes? - _Chai Wah Wu_, Apr 06 2018
%F a(n) = A048412(n)^2.
%t Select[Range[0, 10^7]^2, Or[# == 0, IntegerLength@ # == 1, Union@ Abs@ Differences@ IntegerDigits@ # == {1}] &] (* _Michael De Vlieger_, Nov 25 2016 *)
%o (Haskell)
%o a048411 n = a048411_list !! (n-1)
%o a048411_list = filter ((== 1) . a010052) a033075_list
%o -- _Reinhard Zumkeller_, Feb 21 2012
%o (Python)
%o from sympy.ntheory.primetest import is_square
%o def gen(d, s=None):
%o if d == 0: yield tuple(); return
%o if s == None:
%o yield from [(i, ) + g for i in range(1, 10) for g in gen(d-1, s=i)]
%o else:
%o if s > 0: yield from [(s-1, ) + g for g in gen(d-1, s=s-1)]
%o if s < 9: yield from [(s+1, ) + g for g in gen(d-1, s=s+1)]
%o def afind(maxdigits):
%o print(0, end=", ")
%o for d in range(1, maxdigits+1):
%o for g in gen(d, s=None):
%o t = int("".join(map(str, g)))
%o if is_square(t): print(t, end=", ")
%o afind(17) # _Michael S. Branicky_, Sep 26 2021
%Y Cf. A002477, A048412.
%Y Cf. A010052; intersection of A033075 and A000290.
%K nonn,base,more
%O 1,3
%A _Patrick De Geest_, Apr 15 1999