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.

A068165 Smallest square formed from n by inserting zero or more decimal digits.

This page as a plain text file.
%I A068165 #30 Jan 21 2023 01:59:19
%S A068165 1,25,36,4,25,16,576,81,9,100,121,121,1369,144,1156,16,1764,1089,169,
%T A068165 2025,121,225,2304,324,25,256,2704,289,289,2304,361,324,3136,324,3025,
%U A068165 36,3721,3481,1369,400,441,4225,4356,144,4225,4096,4761,484,49,2500
%N A068165 Smallest square formed from n by inserting zero or more decimal digits.
%C A068165 The digits may be added before, in the middle of, or after the digits of n.
%C A068165 If n is a square then a(n) = n. - _Zak Seidov_, Nov 13 2014
%H A068165 Michael S. Branicky, <a href="/A068165/b068165.txt">Table of n, a(n) for n = 1..10000</a>
%e A068165 Smallest square formed from 20 is 2025, by placing 25 on the right side. Smallest square formed from 33 is 3136, by inserting a 1 between 3's and placing a 6.
%p A068165 A068165 := proc(n)
%p A068165         local b,pdigs,plen,dmas,dmasdigs,i,j;
%p A068165         for b from 1 do
%p A068165                 pdigs := convert(b^2,base,10) ;
%p A068165                 plen := nops(pdigs) ;
%p A068165                 for dmas from 2^plen-1 to 0 by -1 do
%p A068165                         dmasdigs := convert(dmas,base,2) ;
%p A068165                         pdel := [] ;
%p A068165                         for i from 1 to nops(dmasdigs) do
%p A068165                                 if op(i,dmasdigs) = 1 then
%p A068165                                         pdel := [op(pdel),op(i,pdigs)] ;
%p A068165                                 end if;
%p A068165                         end do:
%p A068165                         if n = add(op(j,pdel)*10^(j-1),j=1..nops(pdel)) then
%p A068165                                 return b^2;
%p A068165                         end if;
%p A068165                 end do:
%p A068165         end do:
%p A068165 end proc:
%p A068165 seq(A068165(n),n=1..133) ; # _R. J. Mathar_, Nov 14 2014
%o A068165 (Python)
%o A068165 from math import isqrt
%o A068165 from itertools import count
%o A068165 def dmo(n, t):
%o A068165     if t < n: return False
%o A068165     while n and t:
%o A068165         if n%10 == t%10:
%o A068165             n //= 10
%o A068165         t //= 10
%o A068165     return n == 0
%o A068165 def a(n):
%o A068165     return next(t for t in (i*i for i in count(isqrt(n))) if dmo(n, t))
%o A068165 print([a(n) for n in range(1, 77)]) # _Michael S. Branicky_, Jan 21 2023
%Y A068165 A091873 gives square roots. Cf. A038690, A029944, A068164.
%K A068165 base,easy,nonn
%O A068165 1,2
%A A068165 _Amarnath Murthy_, Feb 25 2002
%E A068165 Corrected and extended by _Ray Chandler_, Oct 11 2003