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!)
A334045 Bitwise NOR of binary representation of n and n-1. 3
0, 0, 0, 0, 2, 0, 0, 0, 6, 4, 4, 0, 2, 0, 0, 0, 14, 12, 12, 8, 10, 8, 8, 0, 6, 4, 4, 0, 2, 0, 0, 0, 30, 28, 28, 24, 26, 24, 24, 16, 22, 20, 20, 16, 18, 16, 16, 0, 14, 12, 12, 8, 10, 8, 8, 0, 6, 4, 4, 0, 2, 0, 0, 0, 62, 60, 60, 56, 58, 56, 56, 48, 54, 52, 52 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,5
COMMENTS
All terms are even.
a(1) = 0, a(2) = 0, and a(2^n + 1) = 2^n - 2 for n > 0. Are there any other cases where n - a(n) < 4? - Charles R Greathouse IV, Apr 13 2020
The answer to the above question is no. Write n as n = (2m+1)*k, i.e. k = A006519(n) is the highest power of 2 dividing n. If m = 0, a(n) = 0 and n - a(n) = n. If m > 0, then a(n) = 2v*k, where v is the 1's complement of m. Thus n-a(n) = (2(m-v)+1)*k. Since m in binary has a leading 1, m - v >= 1 and thus n - a(n) >= 3 with n - a(n) = 3 when n > 2, k = 1 and m - v = 1, i.e. m is a power of 2 and n is of the form 2^r + 1. - Chai Wah Wu, Apr 13 2020
LINKS
EXAMPLE
a(11) = 11 NOR 10 = bin 1011 NOR 1010 = bin 100 = 4.
MAPLE
a:= n-> Bits[Nor](n, n-1):
seq(a(n), n=1..100); # Alois P. Heinz, Apr 13 2020
PROG
(Python)
def norbitwise(n):
a = str(bin(n))[2:]
b = str(bin(n-1))[2:]
if len(b) < len(a):
b = '0' + b
c = ''
for i in range(len(a)):
if a[i] == b[i] and a[i] == '0':
c += '1'
else:
c += '0'
return int(c, 2)
(Python)
def A334045(n):
m = n|(n-1)
return 2**(len(bin(m))-2)-1-m # Chai Wah Wu, Apr 13 2020
(PARI) a(n) = my(x=bitor(n-1, n)); bitneg(x, #binary(x)); \\ Michel Marcus, Apr 13 2020
CROSSREFS
Cf. A038712 (n XOR n-1), A086799 (n OR n-1), A129760 (n AND n-1).
Sequence in context: A358622 A336563 A048146 * A028973 A066503 A057385
KEYWORD
easy,base,nonn
AUTHOR
Christoph Schreier, Apr 13 2020
STATUS
approved

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 19:02 EDT 2024. Contains 371798 sequences. (Running on oeis4.)