[go: up one dir, main page]

login
A142151
a(n) = OR{k XOR (n-k): 0<=k<=n}.
7
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, 29, 30, 27, 30, 29, 30, 31, 62, 61, 62, 59, 62, 61, 62, 55, 62, 61, 62, 59, 62, 61, 62, 47, 62, 61, 62, 59, 62, 61, 62, 55, 62, 61, 62, 59, 62, 61, 62, 63, 126, 125, 126, 123, 126, 125
OFFSET
0,3
LINKS
Reinhard Zumkeller, Logical Convolutions
FORMULA
a(2*n) = 2*(A062383(n)-1);
A023416(a(n)) <= 1.
MAPLE
A142151 := n -> n + Bits:-Nor(n, n+1):
seq(A142151(n), n=0..69); # Peter Luschny, Sep 26 2019
PROG
(Haskell)
import Data.Bits (xor, (.|.))
a142151 :: Integer -> Integer
a142151 = foldl (.|.) 0 . zipWith xor [0..] . reverse . enumFromTo 1
-- Reinhard Zumkeller, Mar 31 2015
(Julia)
using IntegerSequences
A142151List(len) = [Bits("CIMP", n, n+1) for n in 0:len]
println(A142151List(69)) # Peter Luschny, Sep 25 2021
(Python)
from functools import reduce
from operator import or_
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
KEYWORD
nonn,hear,look
AUTHOR
Reinhard Zumkeller, Jul 15 2008
STATUS
approved