OFFSET
1,1
COMMENTS
When a square ends with 4 (A273375), this square may end with precisely one 4, two 4's or three 4's (A328886).
This sequence is infinite as each 2*(10^m + 1), m >= 1 or 2*(10^m + 4), m >= 2 is a term.
Numbers 2, 22, 222, ..., 2*(10^k - 1) / 9, (k >= 1), as well as numbers 2228, 22228, ..., 2*(10^k + 52) / 9, (k >= 4) are terms and have no digits 0. - Marius A. Burtea, Oct 24 2021
EXAMPLE
22 is a term since 22^2 = 484.
638 is not a term since 638^2 = 407044.
668 is not a term since 668^2 = 446224.
MATHEMATICA
Join[{2}, Select[Range[10, 2000], (d = IntegerDigits[#^2])[[1]] == d[[-1]] == 4 && d[[-2]] != 4 && d[[2]] != 4 &]] (* Amiram Eldar, Oct 24 2021 *)
PROG
(PARI) isok(k) = my(d=digits(sqr(k))); (d[1]==4) && (d[#d]==4) && if (#d>2, (d[2]!=4) && (d[#d-1]!=4), 1); \\ Michel Marcus, Oct 24 2021
(Magma) [2] cat [n:n in [4..2300]|Intseq(n*n)[1] eq 4 and Intseq(n*n)[#Intseq(n*n)] eq 4 and Intseq(n*n)[-1+#Intseq(n*n)] ne 4 and Intseq(n*n)[2] ne 4]; // Marius A. Burtea, Oct 24 2021
(Python)
from itertools import count, takewhile
def ok(n):
s = str(n*n); return len(s.rstrip("4")) == len(s.lstrip("4")) == len(s)-1
def aupto(N):
r = takewhile(lambda x: x<=N, (10*i+d for i in count(0) for d in [2, 8]))
return [k for k in r if ok(k)]
print(aupto(2228)) # Michael S. Branicky, Oct 24 2021
KEYWORD
nonn,base
AUTHOR
Bernard Schott, Oct 24 2021
STATUS
approved