login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Sum of leading digit in representations of n in bases 2,3,...,n.
1

%I #40 Aug 03 2014 05:06:14

%S 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,

%T 39,42,43,47,48,52,54,56,58,58,59,61,63,67,68,72,73,76,79,81,82,88,84,

%U 88,90,93,94,99,101,105,107,109,110,116,117,119,122,117,119,123

%N Sum of leading digit in representations of n in bases 2,3,...,n.

%H Jens Kruse Andersen, <a href="/A244912/b244912.txt">Table of n, a(n) for n = 2..1000</a>

%e 8 in bases 2...8 is:

%e 1000 (base 2)

%e 22 (base 3)

%e 20 (base 4)

%e 13 (base 5)

%e 12 (base 6)

%e 11 (base 7)

%e 10 (base 8)

%e The sum of first digits is 1+2+2+1+1+1+1 = 9, so a(8)=9.

%t f[n_] := Sum[ IntegerDigits[n, k][[1]], {k, 2, n}]; Array[f, 70, 2] (* _Robert G. Wilson v_, Aug 02 2014 *)

%o (Python)

%o import math

%o def modlg(a, b):

%o ....return a // b**int(math.log(a, b))

%o for n in range(1,77):

%o ....s=0

%o ....for k in range(2,n+1):

%o ........s += modlg(n,k)

%o ....print str(s)+',',

%o (PARI) a(n) = sum(i=2, n, digits(n, i)[1]); \\ _Michel Marcus_, Jul 17 2014

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

%K nonn,base

%O 2,2

%A _Alex Ratushnyak_, Jul 08 2014