OFFSET
1,2
COMMENTS
The digits may be added before, in the middle of, or after the digits of n.
If n is a square then a(n) = n. - Zak Seidov, Nov 13 2014
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
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.
MAPLE
A068165 := proc(n)
local b, pdigs, plen, dmas, dmasdigs, i, j;
for b from 1 do
pdigs := convert(b^2, base, 10) ;
plen := nops(pdigs) ;
for dmas from 2^plen-1 to 0 by -1 do
dmasdigs := convert(dmas, base, 2) ;
pdel := [] ;
for i from 1 to nops(dmasdigs) do
if op(i, dmasdigs) = 1 then
pdel := [op(pdel), op(i, pdigs)] ;
end if;
end do:
if n = add(op(j, pdel)*10^(j-1), j=1..nops(pdel)) then
return b^2;
end if;
end do:
end do:
end proc:
seq(A068165(n), n=1..133) ; # R. J. Mathar, Nov 14 2014
PROG
(Python)
from math import isqrt
from itertools import count
def dmo(n, t):
if t < n: return False
while n and t:
if n%10 == t%10:
n //= 10
t //= 10
return n == 0
def a(n):
return next(t for t in (i*i for i in count(isqrt(n))) if dmo(n, t))
print([a(n) for n in range(1, 77)]) # Michael S. Branicky, Jan 21 2023
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Amarnath Murthy, Feb 25 2002
EXTENSIONS
Corrected and extended by Ray Chandler, Oct 11 2003
STATUS
approved