login
Characteristic function of A158705, nonnegative integers with an odd number of even powers of 2 in their base-2 representation.
6

%I #39 Jun 21 2024 15:24:01

%S 0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,0,1,

%T 0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,

%U 0,1,0,1,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,1,0

%N Characteristic function of A158705, nonnegative integers with an odd number of even powers of 2 in their base-2 representation.

%H Michael De Vlieger, <a href="/A341389/b341389.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(2n+1) = 1 - a(floor(n/2)) for n >= 0.

%F a(2n) = a(floor(n/2)) for n > 0 with a(0) = 0.

%F a(n) = (-1)^n*a(floor(n/4)) + n mod 2 for n > 0 with a(0) = 0.

%F a(n) = A000035(A139351(n)). - _Antti Karttunen_, Feb 10 2021

%t Array[Mod[Total@ IntegerDigits[#, 4], 2] &, 105, 0] (* _Michael De Vlieger_, Mar 17 2021 *)

%o (PARI) A341389(n) = { my(c=0); while(n, c += (n%2); n >>= 2); (c%2); }; \\ _Antti Karttunen_, Feb 10 2021

%o (PARI) a(n) = sumdigits(n,4) % 2; \\ _Kevin Ryde_, Feb 14 2021

%Y Cf. A000035, A139351, A158704 (positions of zeros), A158705 (of ones).

%Y Cf. A112539 (complement), A112865 (as +-1).

%K nonn

%O 0

%A _Mikhail Kurkov_, Feb 10 2021

%E Terms corrected by _Antti Karttunen_, Feb 10 2021