login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A177718 a(n) = |(number of 1's in binary representation of prime(n)) - (number of 0's in binary representation of prime(n))|. 4

%I #17 Jan 18 2022 15:59:21

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

%T 0,2,2,0,2,2,2,2,6,2,0,2,2,6,2,2,2,6,2,6,5,1,1,1,1,1,1,1,1,3,1,3,1,1,

%U 3,3,1,3,5,3,5,7,1,1,1,1,1,1,5,1,5,5,1,1,3,5,3,7,5,5,5,7,7,4,2,0,2,0,0,0,2

%N a(n) = |(number of 1's in binary representation of prime(n)) - (number of 0's in binary representation of prime(n))|.

%H Karl-Heinz Hofmann, <a href="/A177718/b177718.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = abs(A014499(n) - A035103(n)).

%F a(n) = abs(A037861(prime(n))). - _R. J. Mathar_, May 15 2010

%e a(1)=0 because 2 = 10_2 and abs(1-1) = 0;

%e a(2)=2 because 3 = 11_2 and abs(0-2) = 2;

%e a(3)=1 because 5 = 101_2 and abs(1-2) = 1.

%p A023416 := proc(n) a := 0 ; for d in convert(n,base,2) do if d = 0 then a := a+1 ; end if; end do; a ; end proc:

%p A000120 := proc(n) a := 0 ; for d in convert(n,base,2) do if d = 1 then a := a+1 ; end if; end do; a ; end proc:

%p A037861 := proc(n) A023416(n)-A000120(n) ; end proc:

%p A177718 := proc(n) abs(A037861(ithprime(n))) ; end proc: seq(A177718(n),n=1..120) ; # _R. J. Mathar_, May 15 2010

%p # second Maple program:

%p a:= n-> abs(add(2*i-1, i=Bits[Split](ithprime(n)))):

%p seq(a(n), n=1..105); # _Alois P. Heinz_, Jan 18 2022

%t nzmnu[n_]:=Module[{z=DigitCount[n,2,0]},Abs[2z-IntegerLength[n,2]]]; nzmnu/@ Prime[Range[110]] (* _Harvey P. Dale_, Feb 15 2015 *)

%o (Python) from sympy import isprime

%o print([abs(bin(n)[2:].count("1") - bin(n)[2:].count("0")) for n in range (0,1000) if isprime(n)]) # _Karl-Heinz Hofmann_, Jan 18 2022

%Y Cf. A000040, A000120, A004676.

%K nonn,base

%O 1,2

%A _Juri-Stepan Gerasimov_, May 12 2010, May 18 2010

%E Corrected at three or more places by _R. J. Mathar_, May 15 2010

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 08:28 EDT 2024. Contains 371927 sequences. (Running on oeis4.)