cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A348491 Positive numbers whose square starts and ends with exactly one 9.

This page as a plain text file.
%I A348491 #21 Sep 08 2022 08:46:26
%S A348491 3,97,303,307,313,953,957,963,967,973,977,983,987,993,3003,3007,3013,
%T A348491 3017,3023,3027,3033,3037,3043,3047,3053,3057,3063,3067,3073,3077,
%U A348491 3083,3087,3093,3097,3103,3107,3113,3117,3123,3127,3133,3137,3143,9487,9493,9497,9503,9507,9513,9517
%N A348491 Positive numbers whose square starts and ends with exactly one 9.
%C A348491 When a square ends with 9, it ends with only one 9.
%C A348491 From _Marius A. Burtea_, Nov 02 2021 : (Start)
%C A348491 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.
%C A348491 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, ...
%C A348491 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)
%e A348491 97^2 = 9409, hence 97 is a term.
%e A348491 997^2 = 994009, hence  997 is not a term.
%t A348491 Join[{3}, Select[Range[10, 10^4], (d = IntegerDigits[#^2])[[1]] == d[[-1]] == 9 && d[[2]] != 9 &]] (* _Amiram Eldar_, Nov 02 2021 *)
%o A348491 (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
%o A348491 (Python)
%o A348491 from itertools import count, takewhile
%o A348491 def ok(n):
%o A348491   s = str(n*n); return len(s.rstrip("9")) == len(s.lstrip("9")) == len(s)-1
%o A348491 def aupto(N):
%o A348491   r = takewhile(lambda x: x<=N, (10*i+d for i in count(0) for d in [3, 7]))
%o A348491   return [k for k in r if ok(k)]
%o A348491 print(aupto(9517)) # _Michael S. Branicky_, Nov 02 2021
%o A348491 (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
%o A348491 (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
%Y A348491 Subsequence of A305719, A063226, and A045863.
%Y A348491 Cf. A017377, A045863, A273374 (squares ending with 9).
%Y A348491 Similar to: A348487 (k=1), A348488 (k=4), A348489 (k=5), A348490 (k=6), this sequence (k=9).
%K A348491 nonn,base,easy
%O A348491 1,1
%A A348491 _Bernard Schott_, Nov 02 2021