login
A177718
a(n) = |(number of 1's in binary representation of prime(n)) - (number of 0's in binary representation of prime(n))|.
8
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, 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, 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
OFFSET
1,2
LINKS
FORMULA
a(n) = abs(A014499(n) - A035103(n)).
a(n) = abs(A037861(prime(n))). - R. J. Mathar, May 15 2010
EXAMPLE
a(1)=0 because 2 = 10_2 and abs(1-1) = 0;
a(2)=2 because 3 = 11_2 and abs(0-2) = 2;
a(3)=1 because 5 = 101_2 and abs(1-2) = 1.
MAPLE
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:
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:
A037861 := proc(n) A023416(n)-A000120(n) ; end proc:
A177718 := proc(n) abs(A037861(ithprime(n))) ; end proc: seq(A177718(n), n=1..120) ; # R. J. Mathar, May 15 2010
# second Maple program:
a:= n-> abs(add(2*i-1, i=Bits[Split](ithprime(n)))):
seq(a(n), n=1..105); # Alois P. Heinz, Jan 18 2022
MATHEMATICA
nzmnu[n_]:=Module[{z=DigitCount[n, 2, 0]}, Abs[2z-IntegerLength[n, 2]]]; nzmnu/@ Prime[Range[110]] (* Harvey P. Dale, Feb 15 2015 *)
PROG
(Python) from sympy import isprime
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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Juri-Stepan Gerasimov, May 12 2010, May 18 2010
EXTENSIONS
Corrected at three or more places by R. J. Mathar, May 15 2010
STATUS
approved