cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A121539 Numbers whose binary expansion ends in an even number of 1's.

This page as a plain text file.
%I A121539 #35 Jan 29 2025 14:25:58
%S A121539 0,2,3,4,6,8,10,11,12,14,15,16,18,19,20,22,24,26,27,28,30,32,34,35,36,
%T A121539 38,40,42,43,44,46,47,48,50,51,52,54,56,58,59,60,62,63,64,66,67,68,70,
%U A121539 72,74,75,76,78,79,80,82,83,84,86,88,90,91,92,94,96,98,99,100
%N A121539 Numbers whose binary expansion ends in an even number of 1's.
%C A121539 Equivalently, increasing sequence defined by: "if k appears a*k+b does not", case a(1)=0, a=2, b=1.
%C A121539 Every even number ends with zero 1's and zero is even, so every even number is a term.
%C A121539 Consists of all even numbers together with A131323.
%C A121539 A035263(a(n)) = 1. - _Reinhard Zumkeller_, Mar 01 2012
%H A121539 Reinhard Zumkeller, <a href="/A121539/b121539.txt">Table of n, a(n) for n = 1..10000</a>
%H A121539 Narad Rampersad, Manon Stipulanti, <a href="https://arxiv.org/abs/1807.11899">The Formal Inverse of the Period-Doubling Sequence</a>, arXiv:1807.11899 [math.CO], 2018.
%F A121539 A010060(a(n)) + A010060(a(n)+1) = 1. - _Vladimir Shevelev_, Jun 16 2009
%F A121539 a(n) = A003159(n) - 1. - _Reinhard Zumkeller_, Mar 01 2012
%F A121539 a(n) = (3/2)*n + O(log n). - _Charles R Greathouse IV_, Sep 23 2012
%e A121539 11 in binary is 1011, which ends with two 1's.
%t A121539 s={2}; With[{a=2,b=1},Do[If[FreeQ[s,(n-b)/a],AppendTo[s,n]],{n,3,100}]];s
%o A121539 (Haskell)
%o A121539 import Data.List (elemIndices)
%o A121539 a121539 n = a121539_list !! (n-1)
%o A121539 a121539_list = elemIndices 1 a035263_list
%o A121539 -- _Reinhard Zumkeller_, Mar 01 2012
%o A121539 (PARI) is(n)=valuation(n+1,2)%2==0 \\ _Charles R Greathouse IV_, Sep 23 2012
%o A121539 (Magma) [n: n in [0..200] | Valuation(n+1, 2) mod 2 eq 0 ]; // _Vincenzo Librandi_, Apr 16 2015
%o A121539 (Python)
%o A121539 def ok(n): b = bin(n)[2:]; return (len(b) - len(b.rstrip('1')))%2 == 0
%o A121539 print(list(filter(ok, range(101)))) # _Michael S. Branicky_, Jun 18 2021
%o A121539 (Python)
%o A121539 def A121539(n):
%o A121539     def f(x):
%o A121539         c, s = n+x, bin(x)[2:]
%o A121539         l = len(s)
%o A121539         for i in range(l&1^1,l,2):
%o A121539             c -= int(s[i])+int('0'+s[:i],2)
%o A121539         return c
%o A121539     m, k = n, f(n)
%o A121539     while m != k: m, k = k, f(k)
%o A121539     return m-1 # _Chai Wah Wu_, Jan 29 2025
%Y A121539 Cf. A121538, A121540, A121541, A121542.
%K A121539 nonn,easy
%O A121539 1,2
%A A121539 _Zak Seidov_, Aug 08 2006
%E A121539 Edited by _N. J. A. Sloane_ at the suggestion of _Stefan Steinerberger_, Dec 17 2007