A348491 Positive numbers whose square starts and ends with exactly one 9.
3, 97, 303, 307, 313, 953, 957, 963, 967, 973, 977, 983, 987, 993, 3003, 3007, 3013, 3017, 3023, 3027, 3033, 3037, 3043, 3047, 3053, 3057, 3063, 3067, 3073, 3077, 3083, 3087, 3093, 3097, 3103, 3107, 3113, 3117, 3123, 3127, 3133, 3137, 3143, 9487, 9493, 9497, 9503, 9507, 9513, 9517
Offset: 1
Examples
97^2 = 9409, hence 97 is a term. 997^2 = 994009, hence 997 is not a term.
Crossrefs
Programs
-
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
-
Mathematica
Join[{3}, Select[Range[10, 10^4], (d = IntegerDigits[#^2])[[1]] == d[[-1]] == 9 && d[[2]] != 9 &]] (* Amiram Eldar, 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
-
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
Comments