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!)
A370512 Largest palindromic square which is a concatenation of partitions of n; or 0 if no such number exists. 1

%I #26 Feb 22 2024 09:09:30

%S 1,0,0,121,0,0,0,0,12321,0,0,0,121,0,0,121242121,0,12321,5221225,0,0,

%T 121,0,0,1212225222121,0,12321,5221225,0,0,10201,0,0,1212225222121,0,

%U 12122232623222121

%N Largest palindromic square which is a concatenation of partitions of n; or 0 if no such number exists.

%F a(n) <= A079842(n).

%F If n is a palindromic square, then a(n) >= n.

%e Note that a(4) = a(13) = a(22) = 121 as the digits of 121 can be partitioned as 1+2+1 or 12+1 or 1+21.

%o (Python)

%o from collections import Counter

%o from operator import itemgetter

%o from sympy.ntheory.primetest import is_square

%o from sympy.utilities.iterables import partitions, multiset_permutations

%o def A370512(n):

%o smax, m = 0, 0

%o for s, p in sorted(partitions(n,size=True),key=itemgetter(0),reverse=True):

%o if s<smax:

%o break

%o q = tuple(Counter(p).elements())

%o c = sum((Counter(str(d)) for d in q), start=Counter())

%o if len(tuple(filter(lambda x:x&1,c.values()))) <= 1:

%o for a in multiset_permutations(q):

%o if (b:=''.join(str(d) for d in a))==b[::-1] and is_square(k:=int(b)):

%o m = max(k,m)

%o if m>0:

%o smax=s

%o return m

%Y Cf. A002779, A079842.

%K nonn,more,base

%O 1,4

%A _Chai Wah Wu_, Feb 20 2024

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 May 8 15:25 EDT 2024. Contains 372340 sequences. (Running on oeis4.)