cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-1 of 1 results.

A375968 a(n) is the least number with the same digit average as n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Sep 04 2024

Keywords

Comments

The digit average of a number n is its sum of digits divided by its number of digits: A007953(n) / A055642(n).

Examples

			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
		

Crossrefs

Programs

  • Mathematica
    a[n_]:=Module[{k=0}, While[Mean[IntegerDigits[k]]!=Mean[IntegerDigits[n]], k++]; k]; Array[a,76,0] (* Stefano Spezia, Sep 07 2024 *)
  • 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);); }
Showing 1-1 of 1 results.