login
A079842
Largest square which is a concatenation of partitions of n; or 0 if no such number exists.
2
1, 0, 0, 121, 0, 0, 25, 0, 12321, 2116, 0, 0, 5112121, 0, 0, 121242121, 0, 1121513121, 2511112321, 0, 0, 213223221121, 0, 0, 1212111311221321, 0, 4231211211113121, 1111111222222225, 0, 0, 111131111122142224, 0, 0, 11111111122222222225
OFFSET
1,4
FORMULA
If n is square, then a(n) >= n.
EXAMPLE
a(4) = 121 though 4 itself is a square. a(7) = 25 (16 is also a square).
PROG
(Python)
from collections import Counter
from operator import itemgetter
from sympy.ntheory.primetest import is_square
from sympy.utilities.iterables import partitions, multiset_permutations
def A079842(n):
smax, m = 0, 0
for s, p in sorted(partitions(n, size=True), key=itemgetter(0), reverse=True):
if s<smax:
break
for a in multiset_permutations(Counter(p).elements()):
if is_square(k:=int(''.join(str(d) for d in a))):
m = max(k, m)
if m>0:
smax=s
return m # Chai Wah Wu, Feb 20 2024
CROSSREFS
Sequence in context: A106547 A106544 A370512 * A014756 A014748 A334058
KEYWORD
base,more,nonn
AUTHOR
Amarnath Murthy, Feb 16 2003
EXTENSIONS
More terms from Michel ten Voorde Jun 20 2003
a(23)-a(32) from Chai Wah Wu, Feb 20 2024
a(33)-a(34) from Chai Wah Wu, Feb 21 2024
STATUS
approved