login
Number of 1's in binary representation of n-th prime.
80

%I #49 Mar 27 2023 05:17:57

%S 1,2,2,3,3,3,2,3,4,4,5,3,3,4,5,4,5,5,3,4,3,5,4,4,3,4,5,5,5,4,7,3,3,4,

%T 4,5,5,4,5,5,5,5,7,3,4,5,5,7,5,5,5,7,5,7,2,4,4,5,4,4,5,4,5,6,5,6,5,4,

%U 6,6,4,6,7,6,7,8,4,5,4,5,5,5,7,5,7,7,4,5,6,7,6,8,7,7,7,8,8,3,4

%N Number of 1's in binary representation of n-th prime.

%C a(n) is the rank of prime(n) in the base-2 dominance order on the natural numbers. - _Tom Edgar_, Mar 25 2014

%H T. D. Noe, <a href="/A014499/b014499.txt">Table of n, a(n) for n = 1..10000</a>

%H Tyler Ball and Daniel Juda, <a href="https://scholar.rose-hulman.edu/rhumj/vol14/iss2/2">Dominance over N</a>, Rose-Hulman Undergraduate Mathematics Journal, Vol. 13, No. 2, Fall 2013.

%H Christian Elsholtz, <a href="http://arxiv.org/abs/1602.05974">Almost all primes have a multiple of small Hamming weight</a>, arXiv:1602.05974 [math.NT], 2016.

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(n) = A000120(A000040(n)).

%F a(A049084(A061712(n))) = n. - _Reinhard Zumkeller_, Feb 10 2013

%F a(n) = [x^prime(n)] (1/(1 - x))*Sum_{k>=0} x^(2^k)/(1 + x^(2^k)). - _Ilya Gutkovskiy_, Mar 27 2018

%e From _M. F. Hasler_, Mar 03 2023: (Start)

%e a(n) = 1 only for p(n = 1) = 2, the only prime equal to a power of 2.

%e a(n) = 2 for n in A159611 = A000720(A019434) = {2, 3, 7, 55, 6543} (probably complete), the Fermat primes F[k] = 2^2^k + 1 with k = 0, 1, 2, 3, 4. (On the graph one can distinctly see a(6543) = 2 corresponding to F[4] = 65537.)

%e a(n) = 3 for n in A000720(A081091) = (4, 5, 6, 8, 12, 13, 19, 21, 25, 32, 33, 44, 98, 106, 116, 136, 174, 191, 310, 313, 319, 565, 568, ...). (End)

%t Table[Plus @@ IntegerDigits[Prime[n], 2], {n, 1, 100}] (* _Vincenzo Librandi_, Mar 25 2014 *)

%o (PARI) A014499(n)=hammingweight(prime(n)) \\ _M. F. Hasler_, Nov 20 2009, updated Mar 03 2023

%o (Haskell)

%o a014499 = a000120 . a000040 -- _Reinhard Zumkeller_, Feb 10 2013

%o (Magma) [&+Intseq(NthPrime(n), 2): n in [1..100] ]; // _Vincenzo Librandi_, Mar 25 2014

%o (Sage) [sum(i.digits(base=2)) for i in primes_first_n(200)] # _Tom Edgar_, Mar 25 2014

%o (Python)

%o from sympy import prime

%o def A014499(n): return prime(n).bit_count() # _Chai Wah Wu_, Mar 22 2023

%Y Cf. A035103, A035100, A004676, A090455.

%Y Cf. A027697, A027699

%Y Cf. A180024. - _Reinhard Zumkeller_, Aug 08 2010

%Y Cf. A072084.

%Y Cf. A159611 (indices of 2s), A000720(A081091) (indices of 3s). - _M. F. Hasler_, Mar 03 2023

%K nonn,base,easy

%O 1,2

%A Ingemar Assarsjo (ingemar(AT)binomen.se)