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!)
A048653 Numbers k such that the decimal digits of k^2 can be partitioned into two or more nonzero squares. 4

%I #25 Jul 10 2021 10:50:12

%S 7,12,13,19,21,35,37,38,41,44,57,65,70,107,108,112,119,120,121,125,

%T 129,130,190,191,204,205,209,210,212,223,253,285,305,306,315,342,343,

%U 345,350,369,370,379,380,408,410,413,440,441,475,487,501,538,570,642,650

%N Numbers k such that the decimal digits of k^2 can be partitioned into two or more nonzero squares.

%H Reinhard Zumkeller, <a href="/A048653/b048653.txt">Table of n, a(n) for n = 1..10000</a>

%e 12 is present because 12^2=144 can be partitioned into three squares 1, 4 and 4.

%e 108^2 = 11664 = 1_16_64, 120^2 = 14400 = 1_4_400, so 108 and 120 are in the sequence.

%t (* 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 *)

%o (Haskell)

%o a048653 n = a048653_list !! (n-1)

%o a048653_list = filter (f . show . (^ 2)) [1..] where

%o f zs = g (init $ tail $ inits zs) (tail $ init $ tails zs)

%o g (xs:xss) (ys:yss)

%o | h xs = h ys || f ys || g xss yss

%o | otherwise = g xss yss

%o where h ds = head ds /= '0' && a010052 (read ds) == 1

%o g _ _ = False

%o -- _Reinhard Zumkeller_, Oct 11 2011

%o (Python)

%o from math import isqrt

%o def issquare(n): return isqrt(n)**2 == n

%o def ok(n, c):

%o if n%10 in {2, 3, 7, 8}: return False

%o if issquare(n) and c > 1: return True

%o d = str(n)

%o for i in range(1, len(d)):

%o if d[i] != '0' and issquare(int(d[:i])) and ok(int(d[i:]), c+1):

%o return True

%o return False

%o def aupto(lim): return [r for r in range(lim+1) if ok(r*r, 1)]

%o print(aupto(650)) # _Michael S. Branicky_, Jul 10 2021

%Y Cf. A048646, A048375, A010052, A000290; subsequence of A128783.

%K base,nice,nonn

%O 1,1

%A _Felice Russo_

%E Corrected and extended by _Naohiro Nomoto_, Sep 01 2001

%E Definition clarified by _Harvey P. Dale_, May 09 2021

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 24 05:49 EDT 2024. Contains 371918 sequences. (Running on oeis4.)