A265157 Number of 2's in the base-3 representation of 2^n - 1.
0, 0, 0, 1, 1, 0, 1, 1, 0, 3, 2, 3, 3, 2, 2, 5, 5, 4, 3, 6, 4, 6, 5, 3, 1, 4, 2, 7, 8, 6, 9, 8, 8, 6, 7, 7, 4, 5, 8, 8, 11, 10, 7, 10, 10, 7, 9, 7, 8, 9, 11, 15, 13, 9, 9, 11, 13, 15, 12, 12, 15, 14, 11, 14, 16, 13, 14, 11, 14, 14, 14, 15
Offset: 0
Links
- Indranil Ghosh, Table of n, a(n) for n = 0..1000
Crossrefs
Programs
-
Mathematica
n = -1; While[n < 71, n++; s = IntegerDigits[2^n - 1, 3]; k = Count[s, 2]; AppendTo[a, k]]; a (* after Emmanuel Vantieghem (see A260683)*) Table[DigitCount[2^n-1,3,2],{n,0,80}] (* Harvey P. Dale, Dec 04 2015 *)
-
PARI
a(n) = {my(d = digits(n, 3)); sum(k=1, #d, d[k]==2);} \\ Michel Marcus, Dec 03 2015