OFFSET
0,2
COMMENTS
Positions of ones in A059448 for n >= 1. - John Keith, Mar 09 2022
LINKS
Indranil Ghosh, Table of n, a(n) for n = 0..25000 (terms 0..1000 from T. D. Noe)
Jeffrey Shallit, Additive Number Theory via Automata and Logic, arXiv:2112.13627 [math.NT], 2021.
FORMULA
a(0) = 0, a(2*n) = -a(n) + 6*n + 1, a(2*n+1) = a(n) + 2*n + 2. a(n) = 2*n + 1/2(1-(-1)^A023416(n)) = 2*n + A059448(n). - Ralf Stephan, Sep 17 2003
EXAMPLE
18 is in the sequence because 18 = 10010_2. '10010' has three zeros. - Indranil Ghosh, Feb 04 2017
MAPLE
a:= proc(n) option remember;
if n::even then -a(n/2) + 3*n + 1 else a((n-1)/2) + n + 1 fi
end proc:
a(0):= 0:
seq(a(n), n=0..100); # Robert Israel, Feb 23 2016
MATHEMATICA
Select[Range[0, 150], OddQ[Count[IntegerDigits[#, 2], 0]]&] (* Harvey P. Dale, Oct 22 2011 *)
PROG
(PARI) is(n)=hammingweight(bitneg(n, #binary(n)))%2 \\ Charles R Greathouse IV, Mar 26 2013
(PARI) a(n) = if(n==0, 0, 2*n + (logint(n, 2) - hammingweight(n) + 1) % 2); \\ Kevin Ryde, Mar 11 2021
(Haskell)
a059009 n = a059009_list !! (n-1)
a059009_list = filter (odd . a023416) [1..]
-- Reinhard Zumkeller, Jan 21 2014
(Python)
i=j=0
while j<=800:
if bin(i)[2:].count("0")%2:
print(str(j)+" "+str(i))
j+=1
i+=1 # Indranil Ghosh, Feb 04 2017
(R)
maxrow <- 4 # by choice
onezeros <- 1
for(m in 1:(maxrow+1)){
row <- onezeros[2^(m-1):(2^m-1)]
onezeros <- c(onezeros, c(1-row, row) )
}
a <- which(onezeros == 0)
a
# Yosu Yurramendi, Mar 28 2017
CROSSREFS
KEYWORD
nonn,base,easy,nice
AUTHOR
Patrick De Geest, Dec 15 2000
STATUS
approved