OFFSET
1,3
COMMENTS
Numbers k such that k and the square of k use only the digits 0, 1, 4 and 9.
Notice the trick used in the first Mathematica program to convert decimal numbers to base-4 numbers and then map threes into nines and then twos into fours. This saves a lot of computing. - Robert G. Wilson v, Nov 08 2002
From Robert Israel, Dec 18 2023: (Start)
If k is a term, then so is 10 * k.
Terms that do not end in 0 include
10^(2*j+1) + 5*10^j - 1 for j >= 1, and
10^(2*j+1) + 5*10^(2*j-i) - 10^(2*j-2*i) + 5*10^j - 1 for i >= 1 and j >= 4*i + 3. (End)
LINKS
David A. Corneth, Table of n, a(n) for n = 1..466 (first 68 terms from Jonathan Wellons)
David A. Corneth, PARI program
David A. Corneth, pixelart from first 466 terms in b-file
Jonathan Wellons, Tables of Shared Digits [archived].
EXAMPLE
1049^2 = 1100401, therefore 1049 is a term.
A046030(7)=14 is not a term, as 14^2=196 and 6 is not a square digit.
104900499999000^2 = 11004114900040199000001000000.
MAPLE
M:= 15: # for terms of up to M digits
f:= proc(n, d) n >= 10^(d-1) and convert(convert(n^2, base, 10), set) subset {0, 1, 4, 9} end proc:
g:= proc(n, d) convert(convert(n^2 mod 10^d, base, 10), set) subset {0, 1, 4, 9} end proc:
R:= 0, 1:
C:= [0, 1, 9]:
for d from 2 to M do
C:= select(g, map(t -> (t, t+10^(d-1), t+4*10^(d-1), t+9*10^(d-1)), C), d);
V:= select(f, C, d);
R:= R, op(V);
od:
sort([R]); # Robert Israel, Dec 18 2023
MATHEMATICA
a = {}; Do[d = FromDigits[ ReplaceAll[ IntegerDigits[n, 4], {3 -> 9, 2 -> 4}]]; If[ Union[ Join[ IntegerDigits[d^2], {0, 1, 4, 9}]] == {0, 1, 4, 9}, a = Append[a, d]], {n, 0, 3*10^5}]; a
With[{c={0, 1, 4, 9}}, Select[FromDigits/@Tuples[c, 11], SubsetQ[c, IntegerDigits[ #^2]]&]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jan 15 2017 *)
PROG
(Python)
from itertools import count, islice
def A077429_gen(): # generator of terms
for m in count(0):
s = bin(m)[2:]
if len(s)&1: s='0'+s
n = int(''.join({'00':'0', '01':'1', '10':'4', '11':'9'}[s[i:i+2]] for i in range(0, len(s), 2)))
if set(str(n**2)) <= {'0', '1', '4', '9'}:
yield n
(PARI) See PARI link
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Reinhard Zumkeller, Nov 06 2002
EXTENSIONS
Edited by Robert G. Wilson v, Nov 08 2002
More terms from Jonathan Wellons (wellons(AT)gmail.com), Jan 22 2008
Edited by N. J. A. Sloane, May 15 2008 at the suggestion of R. J. Mathar
STATUS
approved