OFFSET
1,2
COMMENTS
When a square ends with 1, this square ends with exactly one 1.
Sequences A000533 and A253213 show that there are an infinity of terms. The square of their terms, for n >= 3, starts and ends with exactly one 1. Also, the numbers 119, 1119, 11119, ..., ((10^k + 71) / 9)^2, (k >= 3) are terms. The squares ((10^k + 71) / 9)^2, have the last digit 1 and because 12*10^(2*k - 3) < ((10^k + 71) / 9)^2 <13*10^(2*k - 3), for k >= 3, the squares ((10^k + 71) / 9)^2, k >= 4, start with 12. - Marius A. Burtea, Oct 21 2021
EXAMPLE
39 is a term since 39^2 = 1521.
109 is not a term since 109^2 = 11881.
119 is a term since 119^2 = 14161.
MATHEMATICA
Join[{1}, Select[Range[11, 1200], (d = IntegerDigits[#^2])[[1]] == d[[-1]] == 1 && d[[2]] != 1 &]] (* Amiram Eldar, Oct 21 2021 *)
PROG
(Python)
from itertools import count, takewhile
def ok(n):
s = str(n*n); return len(s.rstrip("1")) == len(s.lstrip("1")) == len(s)-1
def aupto(N):
r = takewhile(lambda x: x<=N, (10*i+d for i in count(0) for d in [1, 9]))
return [k for k in r if ok(k)]
print(aupto(1140)) # Michael S. Branicky, Oct 21 2021
(PARI) isok(k) = my(d=digits(sqr(k))); (d[1]==1) && (d[#d]==1) && if (#d>2, (d[2]!=1) && (d[#d-1]!=1), 1); \\ Michel Marcus, Oct 21 2021
(Magma) [1] cat [n:n in [2..1200]|Intseq(n*n)[1] eq 1 and Intseq(n*n)[#Intseq(n*n)] eq 1 and Intseq(n*n)[-1+#Intseq(n*n)] ne 1]; // Marius A. Burtea, Oct 21 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bernard Schott, Oct 21 2021
STATUS
approved