|
|
A348730
|
|
Largest remainder of an n-digit number when divided by its sum of digits.
|
|
6
|
|
|
0, 15, 24, 31, 43, 49, 58, 69, 79, 86, 95, 103, 114, 124, 130, 142, 150, 159, 169, 177, 185, 195, 203, 214, 223, 231, 241, 249, 259, 267, 275, 286, 295, 303, 312, 321, 330, 340, 349, 357, 367, 375, 383, 394, 403, 411, 421, 429, 439, 448, 456, 465, 475, 482, 493, 501
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
When dividing a number by N, the remainder can be at most N - 1. The largest sum of digits that an n-digit number can reach is 9*n. According to this, a(n) < 9*n is always the case.
Is the sequence strictly increasing? a(n) is achieved by a single n-digit number when n = 2, 3, 5, 19, 24, 27, 32, 38, ... (Cf. A348900) - Chai Wah Wu, Nov 02 2021
|
|
LINKS
|
|
|
EXAMPLE
|
79 = 15 mod 16
799 = 24 mod 25
9599 = 31 mod 32
98999 = 43 mod 44
599999 = 49 mod 50
8999998 = 58 mod 61
etc.
|
|
MAPLE
|
sod:=proc(n) # sum of digits
local N;
N:=convert(n, base, 10);
add(i, i=N);
end;
a:=proc(k)local n, i;
for n from 1 to k do
maxR||n:=0: # largest remainder
for i from 10^(n-1) to 10^n-1 do
if i mod sod(i)>maxR||n then
maxR||n:=i mod sod(i);
fi;
od:
od:
return(seq(maxR||n, n=1..k));
end;
|
|
MATHEMATICA
|
a[n_] := Max[Mod[#, (Plus @@ IntegerDigits[#])] & /@ Range[10^(n - 1), 10^n - 1]]; Array[a, 7] (* Amiram Eldar, Oct 31 2021 *)
|
|
PROG
|
(Python)
def sd(n): return sum(map(int, str(n)))
def a(n): return max(n%sd(n) for n in range(10**(n-1)+1, 10**n))
(PARI) See Corneth link
(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, k = 9*n, 0, 10**(n-1)
while l-1 > c:
c = max(c, max(s % l for s in (int(''.join(q)) for p in intpartition(l, n) for q in multiset_permutations(p)) if s >= k))
l -= 1
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|