|
|
A348895
|
|
Largest n-digit number such that the remainder after dividing by sum of digits is A348730(n).
|
|
2
|
|
|
9, 79, 799, 9887, 98999, 999599, 9999968, 99998989, 999989999, 9999989998, 99999999799, 999999999959, 9999999799999, 99999999998999, 999999999999797, 9999999999989999, 99999999999999988, 999999999999979999, 9999999999999998999, 99999899999999999989, 999999999999999899998
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
|
|
LINKS
|
|
|
PROG
|
(Python)
from functools import lru_cache
from sympy.combinatorics.partitions import IntegerPartition
from sympy.utilities.iterables import partitions, multiset_permutations
@lru_cache(maxsize=None)
def intpartition(n, m): return tuple(''.join(str(d) for d in IntegerPartition(p).partition+[0]*(m-s)) for s, p in partitions(n, k=9, m=m, size=True))
l, c, nmax, k = 9*n, 0, 0, 10**(n-1)
while l > c:
for p in intpartition(l, n):
for q in multiset_permutations(p):
w = int(''.join(q))
if w >= k:
wr = w % l
if wr > c:
c = wr
nmax = w
if wr == c and nmax < w:
nmax = w
l -= 1
return nmax
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|