login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A068165 Smallest square formed from n by inserting zero or more decimal digits. 9

%I #30 Jan 21 2023 01:59:19

%S 1,25,36,4,25,16,576,81,9,100,121,121,1369,144,1156,16,1764,1089,169,

%T 2025,121,225,2304,324,25,256,2704,289,289,2304,361,324,3136,324,3025,

%U 36,3721,3481,1369,400,441,4225,4356,144,4225,4096,4761,484,49,2500

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

%C The digits may be added before, in the middle of, or after the digits of n.

%C If n is a square then a(n) = n. - _Zak Seidov_, Nov 13 2014

%H Michael S. Branicky, <a href="/A068165/b068165.txt">Table of n, a(n) for n = 1..10000</a>

%e 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 := proc(n)

%p local b,pdigs,plen,dmas,dmasdigs,i,j;

%p for b from 1 do

%p pdigs := convert(b^2,base,10) ;

%p plen := nops(pdigs) ;

%p for dmas from 2^plen-1 to 0 by -1 do

%p dmasdigs := convert(dmas,base,2) ;

%p pdel := [] ;

%p for i from 1 to nops(dmasdigs) do

%p if op(i,dmasdigs) = 1 then

%p pdel := [op(pdel),op(i,pdigs)] ;

%p end if;

%p end do:

%p if n = add(op(j,pdel)*10^(j-1),j=1..nops(pdel)) then

%p return b^2;

%p end if;

%p end do:

%p end do:

%p end proc:

%p seq(A068165(n),n=1..133) ; # _R. J. Mathar_, Nov 14 2014

%o (Python)

%o from math import isqrt

%o from itertools import count

%o def dmo(n, t):

%o if t < n: return False

%o while n and t:

%o if n%10 == t%10:

%o n //= 10

%o t //= 10

%o return n == 0

%o def a(n):

%o return next(t for t in (i*i for i in count(isqrt(n))) if dmo(n, t))

%o print([a(n) for n in range(1, 77)]) # _Michael S. Branicky_, Jan 21 2023

%Y A091873 gives square roots. Cf. A038690, A029944, A068164.

%K base,easy,nonn

%O 1,2

%A _Amarnath Murthy_, Feb 25 2002

%E Corrected and extended by _Ray Chandler_, Oct 11 2003

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 29 08:40 EDT 2024. Contains 372098 sequences. (Running on oeis4.)