A159913 a(n) = 2^(A000120(n) + 1) - 1, where A000120(n) = number of nonzero bits in n.
1, 3, 3, 7, 3, 7, 7, 15, 3, 7, 7, 15, 7, 15, 15, 31, 3, 7, 7, 15, 7, 15, 15, 31, 7, 15, 15, 31, 15, 31, 31, 63, 3, 7, 7, 15, 7, 15, 15, 31, 7, 15, 15, 31, 15, 31, 31, 63, 7, 15, 15, 31, 15, 31, 31, 63, 15, 31, 31, 63, 31, 63, 63, 127, 3, 7, 7, 15, 7, 15, 15, 31, 7, 15, 15, 31, 15, 31, 31
Offset: 0
Keywords
Examples
From _Michael De Vlieger_, Jan 25 2016: (Start) The number n converted to binary, "0" represented by "." for better visibility of 1's, totaling the 1's and calculating the sequence: n Binary Total a(n) 0 -> . -> 0, thus 2^(0+1)-1 = 2-1 = 1 1 -> 1 -> 1, " 2^(1+1)-1 = 4-1 = 3 2 -> 1. -> 1, " 2^(1+1)-1 = 4-1 = 3 3 -> 11 -> 2, " 2^(2+1)-1 = 8-1 = 7 4 -> 1.. -> 1, " 2^(1+1)-1 = 4-1 = 3 5 -> 1.1 -> 2, " 2^(2+1)-1 = 8-1 = 7 6 -> 11. -> 2, " 2^(2+1)-1 = 8-1 = 7 7 -> 111 -> 3, " 2^(3+1)-1 = 16-1 = 15 8 -> 1... -> 1, " 2^(1+1)-1 = 4-1 = 3 9 -> 1..1 -> 2, " 2^(2+1)-1 = 8-1 = 7 10-> 1.1. -> 2, " 2^(2+1)-1 = 8-1 = 7 (End)
Links
Crossrefs
Programs
-
Mathematica
Table[2^(DigitCount[n, 2][[1]] + 1) - 1, {n, 0, 78}] (* or *) Table[2^(Total@ IntegerDigits[n, 2] + 1) - 1, {n, 0, 78}] (* Michael De Vlieger, Jan 25 2016 *)
-
PARI
A159913(n)=2<
-
Python
def A159913(n): return (1<
Chai Wah Wu, Nov 15 2022
Formula
a(n) = A160019(n,n). - Philippe Deléham, Nov 15 2011
a(n) = n - Sum_{k=0..n} (-1)^binomial(n, k). - Peter Luschny, Jan 14 2018
Comments