login
A375968
a(n) is the least number with the same digit average as n.
3
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 12, 2, 14, 3, 16, 4, 18, 5, 1, 12, 2, 14, 3, 16, 4, 18, 5, 29, 12, 2, 14, 3, 16, 4, 18, 5, 29, 6, 2, 14, 3, 16, 4, 18, 5, 29, 6, 49, 14, 3, 16, 4, 18, 5, 29, 6, 49, 7, 3, 16, 4, 18, 5, 29, 6, 49, 7, 69, 16, 4, 18, 5, 29, 6
OFFSET
0,3
COMMENTS
The digit average of a number n is its sum of digits divided by its number of digits: A007953(n) / A055642(n).
LINKS
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