login
Number of bits in binary expansion of n-th prime.
55

%I #42 Nov 19 2024 17:01:51

%S 2,2,3,3,4,4,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,

%T 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,

%U 9,9,9,9,9,9,9,9,9,9,9,9,9

%N Number of bits in binary expansion of n-th prime.

%H Jamie Morken, <a href="/A035100/b035100.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from G. C. Greubel)

%p Digits := 40: [ seq(1+floor(evalf(log(ithprime(n))/log(2))), n=1..100) ];

%t f[n_]:=Length[IntegerDigits[Prime[n],2]]; Table[f[n],{n,5!}] (* _Vladimir Joseph Stephan Orlovsky_, Feb 07 2010 *)

%t IntegerLength[Prime[Range[100]],2] (* _Harvey P. Dale_, Nov 10 2022 *)

%o (PARI) a(n)=#binary(prime(n)) \\ _Charles R Greathouse IV_, Sep 23 2012

%o (Python)

%o from sympy import prime

%o def A035100(n): return prime(n).bit_length() # _Chai Wah Wu_, Nov 19 2024

%Y Cf. A000040, A000523, A029837, A070939, A162145.

%K nonn,easy,changed

%O 1,1

%A _N. J. A. Sloane_