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.

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

This page as a plain text file.
%I A375968 #12 Sep 08 2024 07:54:41
%S A375968 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,
%T A375968 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,
%U A375968 29,6,49,7,3,16,4,18,5,29,6,49,7,69,16,4,18,5,29,6
%N A375968 a(n) is the least number with the same digit average as n.
%C A375968 The digit average of a number n is its sum of digits divided by its number of digits: A007953(n) / A055642(n).
%H A375968 Rémy Sigrist, <a href="/A375968/b375968.txt">Table of n, a(n) for n = 0..10000</a>
%e A375968 The first terms, alongside the corresponding digit average, are:
%e A375968   n   a(n)  Digit average
%e A375968   --  ----  -------------
%e A375968    0     0              0
%e A375968    1     1              1
%e A375968    2     2              2
%e A375968    3     3              3
%e A375968    4     4              4
%e A375968    5     5              5
%e A375968    6     6              6
%e A375968    7     7              7
%e A375968    8     8              8
%e A375968    9     9              9
%e A375968   10    10            1/2
%e A375968   11     1              1
%e A375968   12    12            3/2
%e A375968   13     2              2
%e A375968   14    14            5/2
%e A375968   15     3              3
%t A375968 a[n_]:=Module[{k=0}, While[Mean[IntegerDigits[k]]!=Mean[IntegerDigits[n]], k++]; k]; Array[a,76,0] (* _Stefano Spezia_, Sep 07 2024 *)
%o A375968 (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);); }
%Y A375968 Cf. A007953, A055642, A342829, A375967, A375969.
%K A375968 nonn,base
%O A375968 0,3
%A A375968 _Rémy Sigrist_, Sep 04 2024