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.

A030666 Smallest nontrivial extension of n which is a square.

This page as a plain text file.
%I A030666 #22 Apr 25 2020 02:01:47
%S A030666 16,25,36,49,529,64,729,81,900,100,1156,121,1369,144,1521,169,1764,
%T A030666 1849,196,2025,2116,225,2304,2401,256,2601,2704,289,2916,3025,3136,
%U A030666 324,3364,3481,35344,361,3721,3844,3969,400,41209,4225,4356,441
%N A030666 Smallest nontrivial extension of n which is a square.
%C A030666 A trivial extension would mean appending no digits at all when n is already a square. With trivial extensions allowed, this sequence becomes A018796.
%H A030666 N. J. A. Sloane, <a href="/A030666/b030666.txt">Table of n, a(n) for n = 1..20000</a>
%F A030666 a(n) = A030667(n)^2.
%e A030666 80 is not a perfect square, but 81 = 9^2, so a(8) = 81.
%e A030666 Although 9 is already a square, we need to append at least one digit. However, none of 90, 91, 92, ..., 99 are squares. Then we try 900 = 30^2, so a(9) = 900.
%p A030666 # Program which computes 20000 terms, from _N. J. A. Sloane_, Nov 24 2015
%p A030666 for b from 1 to 20000 do
%p A030666 sw1:=-1:
%p A030666 for p from 1 to 6 do
%p A030666 bp:=b*10^p;
%p A030666 for i from 0 to 10^p-1 do
%p A030666 if issqr(bp+i) then lprint(b,bp+i); sw1:=1; break; fi;
%p A030666                        od:
%p A030666 if sw1 > 0 then break; fi;
%p A030666                  od:
%p A030666 if sw1 < 0 then lprint("failed at b = ",b); fi;
%p A030666                       od:
%o A030666 (Python)
%o A030666 from gmpy2 import isqrt
%o A030666 def A030666(n):
%o A030666     d, nd = 10, 10*n
%o A030666     while True:
%o A030666         x = (isqrt(nd-1)+1)**2
%o A030666         if x < nd+d:
%o A030666             return int(x)
%o A030666         d *= 10
%o A030666         nd *= 10 # _Chai Wah Wu_, May 24 2016
%Y A030666 Cf. A030667, A030686, A018796.
%Y A030666 See A264604 for another version (first differs at a(9)).
%K A030666 nonn,base
%O A030666 1,1
%A A030666 _Patrick De Geest_