|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,4
|
|
LINKS
|
|
|
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
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
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,more,nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|