OFFSET
1,1
COMMENTS
When a square ends with 9, it ends with only one 9.
From Marius A. Burtea, Nov 02 2021 : (Start)
The sequence is infinite because the numbers 303, 3003, 30003, ..., 3*(10^k + 1), k >= 2, are terms with squares 91809, 9018009, 900180009, 90001800009, ... 9*(10^(2*k) + 2*10^k + 1), k >= 2.
Numbers 97, 967, 9667, 96667, 966667, ..., (29*10^n + 1) / 3, k >= 1, are terms and have no digits 0, because their squares are 9409, 935089, 93450889, 9344508889, 934445088889, ...
Also 963, 9663, 96663, 966663, 9666663, 96666663, ... (29*10^k - 11) / 3, k >= 2, are terms and have no digits 0, because their squares are 927369, 93373569, 9343735569, 934437355569, 93444373555569, 9344443735555569, ... (End)
EXAMPLE
97^2 = 9409, hence 97 is a term.
997^2 = 994009, hence 997 is not a term.
MATHEMATICA
Join[{3}, Select[Range[10, 10^4], (d = IntegerDigits[#^2])[[1]] == d[[-1]] == 9 && d[[2]] != 9 &]] (* Amiram Eldar, Nov 02 2021 *)
PROG
(Magma) [3] cat [n:n in [4..9600]|Intseq(n*n)[1] eq 9 and Intseq(n*n)[#Intseq(n*n)] eq 9]; // Marius A. Burtea, Nov 02 2021
(Python)
from itertools import count, takewhile
def ok(n):
s = str(n*n); return len(s.rstrip("9")) == len(s.lstrip("9")) == len(s)-1
def aupto(N):
r = takewhile(lambda x: x<=N, (10*i+d for i in count(0) for d in [3, 7]))
return [k for k in r if ok(k)]
print(aupto(9517)) # Michael S. Branicky, Nov 02 2021
(PARI) isok(k) = my(d=digits(sqr(k))); (d[1]==9) && (d[#d]==9) && if (#d>2, (d[2]!=9) && (d[#d-1]!=9), 1); \\ Michel Marcus, Nov 03 2021
(PARI) list(lim)=my(v=List([3])); for(d=2, 2*#digits(lim\=1), my(s=sqrtint(9*10^(d-1)-1)+1); s+=[3, 2, 1, 0, 3, 2, 1, 0, 5, 4][s%10+1]; forstep(n=s, min(sqrtint(10^d-10^(d-2)-1), lim), if(s%10==3, [4, 6], [6, 4]), listput(v, n))); Vec(v) \\ Charles R Greathouse IV, Nov 03 2021
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Bernard Schott, Nov 02 2021
STATUS
approved