A100714 Number of runs in binary expansion of A000040(n) (the n-th prime number) for n > 0.
2, 1, 3, 1, 3, 3, 3, 3, 3, 3, 1, 5, 5, 5, 3, 5, 3, 3, 3, 3, 5, 3, 5, 5, 3, 5, 3, 5, 5, 3, 1, 3, 5, 5, 7, 5, 5, 5, 5, 7, 5, 7, 3, 3, 5, 3, 5, 3, 3, 5, 5, 3, 3, 3, 3, 3, 5, 3, 7, 5, 5, 7, 5, 5, 5, 5, 7, 7, 7, 7, 5, 5, 5, 7, 5, 3, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 3, 5, 5, 3, 5, 3, 3, 5, 3, 3, 3, 5, 5, 5, 5, 7, 5, 5, 5
Offset: 1
Examples
a(5)=3 because A000040(5) = 11_10 = 1011_2, which splits into three runs ({1}, {0}, {1,1}).
Links
- Eric Weisstein's World of Mathematics, Run-Length Encoding.
Programs
-
Maple
A100714 := proc(n) A005811(ithprime(n)) ; end proc: seq( A100714(n),n=1..105) ; # R. J. Mathar, Jul 08 2025
-
Mathematica
Table[Length[Split[IntegerDigits[Prime[n], 2]]], {n, 1, 128}]
-
PARI
a(n,p=prime(n))=hammingweight(bitxor(p, p>>1)) \\ Charles R Greathouse IV, Oct 19 2015
-
Python
from sympy import prime def a(n): return ((p:=prime(n))^(p>>1)).bit_count() print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Feb 25 2023
Comments