|
|
A079840
|
|
Largest multiple of n as a concatenation of its partitions.
|
|
1
|
|
|
1, 2, 111, 112, 5, 11112, 21112, 1111112, 111111111, 10, 110, 11111111112, 21112111111, 112111111112, 11111111115, 11111111112112, 211111111121111, 11111111111111112, 21111111211111111, 20, 21111111111111111111, 21111111111111111112, 211121111111111111111
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
Any ordering of terms of the partition can be used before concatenation. - D. S. McNeil, May 09 2010
|
|
LINKS
|
|
|
EXAMPLE
|
a(4) = 112: the partitions of 4 are 4,(3,1),(2,2),(1,1,2),(1,1,1,1). There are two multiples of 4, i.e., 4 and 112.
a(6) = 11112 (all partitions with one even part give multiples of 6 and 11112 is the largest).
|
|
PROG
|
(Python)
from collections import Counter
from operator import itemgetter
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
if n % 10 or '0' in ''.join(str(d%10) for d in p):
for a in multiset_permutations(Counter(p).elements()):
if not (k:=int(''.join(str(d) for d in a))) % n:
m = max(k, m)
if m>0:
smax=s
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|