OFFSET
1,2
LINKS
Karl-Heinz Hofmann, Table of n, a(n) for n = 1..10000
FORMULA
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:
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