OFFSET
0,3
COMMENTS
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
EXAMPLE
The first terms, alongside the corresponding digit average, are:
n a(n) Digit average
-- ---- -------------
0 0 0
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 10 1/2
11 1 1
12 12 3/2
13 2 2
14 14 5/2
15 3 3
MATHEMATICA
a[n_]:=Module[{k=0}, While[Mean[IntegerDigits[k]]!=Mean[IntegerDigits[n]], k++]; k]; Array[a, 76, 0] (* Stefano Spezia, Sep 07 2024 *)
PROG
(PARI) a(n, base = 10) = { my (d = digits(n, base), avg = vecsum(d) / max(1, #d)); if (avg==0, 0, my (t = vector(denominator(avg)), r = numerator(avg), x); t[1] = 1; r--; forstep (k = #t, 1, -1, t[k] += x = min(r, base-1); r -= x; ); fromdigits(t, base); ); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Sep 04 2024
STATUS
approved