login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A142151 a(n) = OR{k XOR (n-k): 0<=k<=n}. 7

%I #25 Jun 30 2022 18:00:55

%S 0,1,2,3,6,5,6,7,14,13,14,11,14,13,14,15,30,29,30,27,30,29,30,23,30,

%T 29,30,27,30,29,30,31,62,61,62,59,62,61,62,55,62,61,62,59,62,61,62,47,

%U 62,61,62,59,62,61,62,55,62,61,62,59,62,61,62,63,126,125,126,123,126,125

%N a(n) = OR{k XOR (n-k): 0<=k<=n}.

%H Reinhard Zumkeller, <a href="/A142151/b142151.txt">Table of n, a(n) for n = 0..10000</a>

%H Reinhard Zumkeller, <a href="/A142149/a142149.txt">Logical Convolutions</a>

%F a(2*n) = 2*(A062383(n)-1);

%F A023416(a(n)) <= 1.

%p A142151 := n -> n + Bits:-Nor(n, n+1):

%p seq(A142151(n), n=0..69); # _Peter Luschny_, Sep 26 2019

%o (Haskell)

%o import Data.Bits (xor, (.|.))

%o a142151 :: Integer -> Integer

%o a142151 = foldl (.|.) 0 . zipWith xor [0..] . reverse . enumFromTo 1

%o -- _Reinhard Zumkeller_, Mar 31 2015

%o (Julia)

%o using IntegerSequences

%o A142151List(len) = [Bits("CIMP", n, n+1) for n in 0:len]

%o println(A142151List(69)) # _Peter Luschny_, Sep 25 2021

%o (Python)

%o from functools import reduce

%o from operator import or_

%o def A142151(n): return 0 if n == 0 else reduce(or_,(k^n-k for k in range(n+1))) if n % 2 else (1 << n.bit_length()-1)-1 <<1 # _Chai Wah Wu_, Jun 30 2022

%Y Cf. A003817, A000004, A142149, A086099, A142150, A001477, A089633.

%K nonn,hear,look

%O 0,3

%A _Reinhard Zumkeller_, Jul 15 2008

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 18:05 EDT 2024. Contains 371798 sequences. (Running on oeis4.)