OFFSET
1,1
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
EXAMPLE
12 is present because 12^2=144 can be partitioned into three squares 1, 4 and 4.
108^2 = 11664 = 1_16_64, 120^2 = 14400 = 1_4_400, so 108 and 120 are in the sequence.
MATHEMATICA
(* This non-optimized program is not suitable to compute a large number of terms. *) split[digits_, pos_] := Module[{pos2}, pos2 = Transpose[{Join[ {1}, Most[pos+1]], pos}]; FromDigits[Take[digits, {#[[1]], #[[2]]}]]& /@ pos2]; sel[n_] := Module[{digits, ip, ip2, accu, nn}, digits = IntegerDigits[n^2]; ip = IntegerPartitions[Length[digits]]; ip2 = Flatten[ Permutations /@ ip, 1]; accu = Accumulate /@ ip2; nn = split[ digits, #]& /@ accu; SelectFirst[nn, Length[#]>1 && Flatten[ IntegerDigits[#] ] == digits && AllTrue[#, #>0 && IntegerQ[Sqrt[#]]&]&] ]; k = 1; Reap[Do[If[(s = sel[n]) != {}, Print["a(", k++, ") = ", n, " ", n^2, " ", s]; Sow[n]], {n, 1, 10^4}]][[2, 1]] (* Jean-François Alcover, Sep 28 2016 *)
PROG
(Haskell)
a048653 n = a048653_list !! (n-1)
a048653_list = filter (f . show . (^ 2)) [1..] where
f zs = g (init $ tail $ inits zs) (tail $ init $ tails zs)
g (xs:xss) (ys:yss)
| h xs = h ys || f ys || g xss yss
| otherwise = g xss yss
where h ds = head ds /= '0' && a010052 (read ds) == 1
g _ _ = False
-- Reinhard Zumkeller, Oct 11 2011
(Python)
from math import isqrt
def issquare(n): return isqrt(n)**2 == n
def ok(n, c):
if n%10 in {2, 3, 7, 8}: return False
if issquare(n) and c > 1: return True
d = str(n)
for i in range(1, len(d)):
if d[i] != '0' and issquare(int(d[:i])) and ok(int(d[i:]), c+1):
return True
return False
def aupto(lim): return [r for r in range(lim+1) if ok(r*r, 1)]
print(aupto(650)) # Michael S. Branicky, Jul 10 2021
CROSSREFS
KEYWORD
base,nice,nonn
AUTHOR
EXTENSIONS
Corrected and extended by Naohiro Nomoto, Sep 01 2001
Definition clarified by Harvey P. Dale, May 09 2021
STATUS
approved