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.

A244912 Sum of leading digits in representations of n in bases 2,3,...,n.

Original entry on oeis.org

1, 2, 3, 4, 6, 7, 9, 9, 11, 12, 15, 16, 18, 20, 20, 21, 25, 26, 29, 31, 33, 34, 38, 36, 38, 39, 42, 43, 47, 48, 52, 54, 56, 58, 58, 59, 61, 63, 67, 68, 72, 73, 76, 79, 81, 82, 88, 84, 88, 90, 93, 94, 99, 101, 105, 107, 109, 110, 116, 117, 119, 122, 117, 119, 123
Offset: 2

Views

Author

Alex Ratushnyak, Jul 08 2014

Keywords

Examples

			8 in bases 2...8 is:
  1000 (base 2)
  22 (base 3)
  20 (base 4)
  13 (base 5)
  12 (base 6)
  11 (base 7)
  10 (base 8)
The sum of first digits is 1+2+2+1+1+1+1 = 9, so a(8)=9.
		

Crossrefs

Cf. A004125 (sum of last digits), A043306 (sum of all digits).

Programs

  • Mathematica
    f[n_] := Sum[ IntegerDigits[n, k][[1]], {k, 2, n}]; Array[f, 70, 2] (* Robert G. Wilson v, Aug 02 2014 *)
  • PARI
    a(n) = sum(i=2, n, digits(n, i)[1]); \\ Michel Marcus, Jul 17 2014
  • Python
    import math
    def modlg(a, b):
        return a // b**int(math.log(a, b))
    for n in range(2,77):
        s=0
        for k in range(2,n+1):
            s += modlg(n,k)
        print(s, end=', ')
    

Formula

a(n) = Sum_{k=2..n} floor(n/f(n,k)), with f(n,k) = k^floor(log_k(n)). - Ridouane Oudra, Apr 26 2025