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.

Previous Showing 11-20 of 29 results. Next

A285326 a(0) = 0, for n > 0, a(n) = n + A006519(n).

Original entry on oeis.org

0, 2, 4, 4, 8, 6, 8, 8, 16, 10, 12, 12, 16, 14, 16, 16, 32, 18, 20, 20, 24, 22, 24, 24, 32, 26, 28, 28, 32, 30, 32, 32, 64, 34, 36, 36, 40, 38, 40, 40, 48, 42, 44, 44, 48, 46, 48, 48, 64, 50, 52, 52, 56, 54, 56, 56, 64, 58, 60, 60, 64, 62, 64, 64, 128, 66, 68, 68, 72, 70, 72, 72, 80, 74, 76, 76, 80, 78, 80, 80, 96, 82, 84, 84, 88, 86, 88, 88, 96, 90, 92, 92
Offset: 0

Views

Author

Antti Karttunen, Apr 19 2017

Keywords

Comments

From M. F. Hasler, Oct 19 2019: (Start)
This sequence is equal to itself multiplied by 2 and interleaved with the positive even numbers: We have a(2n-1) = 2n (n >= 1) from the very definition, since A006519(m) = 1 for odd m. And a(2n) = 2n + A006519(2n) = 2*a(n), using A006519(2n) = 2*A006519(n).
The sequence repeats the pattern [A, B, C, C] where in the n-th occurrence C = 4n, B = C - 2, A = C if n is even, A = C + 4 if n = 3 (mod 4), and A = 16*a((n-1)/4) otherwise. (End)

Crossrefs

Row 2 of A285325 (after the initial zero).
Cf. A109168 (same terms divided by 2), also A140472.

Programs

Formula

a(0) = 0; for n > 0, a(n) = n + A006519(n).
For n >= 1, a(n) = 2*A109168(n).
a(n) = 2*A140472(n) and a(2n) = 2*a(n) and a(2^n) = 2^(n+1) for all n >= 0, a(2n-1) = 2n for all n >= 1. - M. F. Hasler, Oct 19 2019

A339597 When 2*n+1 first appears in A086799.

Original entry on oeis.org

1, 2, 5, 4, 9, 10, 13, 8, 17, 18, 21, 20, 25, 26, 29, 16, 33, 34, 37, 36, 41, 42, 45, 40, 49, 50, 53, 52, 57, 58, 61, 32, 65, 66, 69, 68, 73, 74, 77, 72, 81, 82, 85, 84, 89, 90, 93, 80, 97, 98, 101, 100, 105, 106, 109, 104, 113, 114, 117, 116, 121, 122, 125, 64, 129, 130, 133, 132, 137
Offset: 0

Views

Author

Marc LeBrun and N. J. A. Sloane, Jan 06 2021

Keywords

Crossrefs

Cf. A086799, A091072 (terms sorted), A129760.

Programs

  • Maple
    N := 127: # for a(0) to a(N)
    V := Array(0..N): count := 0:
    for i from 1 while count < N+1 do
      with(MmaTranslator[Mma]):
      f(i) := BitOr(i,i-1);
      v := (f(i)-1)/2;
      if v <= N and V[v] = 0 then count := count+1; V[v] := i fi
    od:
    convert(V,list); # Robert Israel, Jan 07 2021
  • PARI
    f(n) = bitor(n, n-1); \\ A086799
    a(n) = my(k=1); while (f(k) != 2*n+1, k++); k; \\ Michel Marcus, Jan 07 2021
    
  • PARI
    a(n) = n++; n<<1 - 1<Kevin Ryde, Mar 29 2021
    
  • Python
    def A339597(n): return ((m:=n+1)<<1)-(m&-m) # Chai Wah Wu, Sep 01 2023

Formula

a(n) = 2*(n+1) - A006519(n+1) = n+1 with a 0 bit inserted above its least significant 1-bit. - Kevin Ryde, Mar 29 2021
a(n) = A129760(n+1) + n+1. - Christian Krause, May 05 2021

A298011 If n = Sum_{i=1..h} 2^b_i with 0 <= b_1 < ... < b_h, then a(n) = Sum_{i=1..h} i * 2^b_i.

Original entry on oeis.org

0, 1, 2, 5, 4, 9, 10, 17, 8, 17, 18, 29, 20, 33, 34, 49, 16, 33, 34, 53, 36, 57, 58, 81, 40, 65, 66, 93, 68, 97, 98, 129, 32, 65, 66, 101, 68, 105, 106, 145, 72, 113, 114, 157, 116, 161, 162, 209, 80, 129, 130, 181, 132, 185, 186, 241, 136, 193, 194, 253, 196
Offset: 0

Views

Author

Rémy Sigrist, Jan 10 2018

Keywords

Comments

This sequence is similar to A298043.

Examples

			For n = 42:
- 42 = 2 + 8 + 32,
- hence a(42) = 1*2 + 2*8 + 3*32 = 114.
		

Crossrefs

Programs

  • Maple
    F[0]:= x -> x:
    for i from 1 to 8 do
      F[i]:= unapply(convert(series(2*(x+1)*F[i-1](x^2)+H, x, 2^(i+1)),
        polynom), x)
    od:
    seq(coeff(F[8](x),x,j),j=0..2^9-1); # Robert Israel, Jan 16 2018
  • Mathematica
    a[0] = 0; a[n_] := a[n] = If[OddQ[n], a[n - 1] + n, 2*a[n/2]]; Array[a, 100, 0] (* Amiram Eldar, Jul 24 2023 *)
  • PARI
    a(n) = my (b=binary(n), z=0); forstep (i=#b, 1, -1, if (b[i], b[i] = z++)); return (fromdigits(b, 2))
    
  • PARI
    first(n) = n += (n-1)%2; my(res = vector(n)); res[1]= 1; for(i = 1, n\2, res[2 * i] = 2 * res[i]; res[2 * i + 1] = res[2 * i] + 2*i + 1); concat([0], res) \\ David A. Corneth, Jan 14 2018

Formula

a(n) = Sum_{k = 0..A000120(n)-1} A129760^k(n) for any n > 0 (where A129760^k denotes the k-th iterate of A129760).
a(n) >= n with equality iff n = 0 or n = 2^k for some k >= 0.
a(2 * n) = 2 * a(n).
a(2^n - 1) = A000337(n).
a(2 * n + 1) = a(2 * n) + 2 * n + 1. David A. Corneth, Jan 14 2018
G.f. g(x) satisfies g(x) = 2*(x+1)*g(x^2) + x*(1+x^2)/(1-x^2)^2. - Robert Israel, Jan 16 2018

A328473 a(n) = A276156(n) - A002110(A007814(n)).

Original entry on oeis.org

0, 0, 2, 0, 6, 6, 8, 0, 30, 30, 32, 30, 36, 36, 38, 0, 210, 210, 212, 210, 216, 216, 218, 210, 240, 240, 242, 240, 246, 246, 248, 0, 2310, 2310, 2312, 2310, 2316, 2316, 2318, 2310, 2340, 2340, 2342, 2340, 2346, 2346, 2348, 2310, 2520, 2520, 2522, 2520, 2526, 2526, 2528, 2520, 2550, 2550, 2552, 2550, 2556, 2556, 2558, 0, 30030
Offset: 1

Views

Author

Antti Karttunen, Oct 18 2019

Keywords

Comments

A276156(n) converts the binary expansion of n to a number whose primorial base representation has the same digits of 0's and 1's, thus each one of its terms is a unique sum of distinct primorial numbers. This sequence is otherwise similar, but the primorial number corresponding to the least significant 1-bit of n is dropped from the sum, so the sum is not unique anymore.

Crossrefs

Programs

  • PARI
    A002110(n) = prod(i=1,n,prime(i));
    A276156(n) = { my(p=2,pr=1,s=0); while(n,if(n%2,s += pr); n >>= 1; pr *= p; p = nextprime(1+p)); (s); };
    A328473(n) = (A276156(n)-A002110(valuation(n,2)));

Formula

a(n) = A276156(A129760(n)).
a(n) = A276151(A276156(n)) = A276156(n) - A002110(A007814(n)).

A059991 a(n) = 2^(n-2^ord_2(n)) (or 2^(n-A006519(n))).

Original entry on oeis.org

1, 1, 4, 1, 16, 16, 64, 1, 256, 256, 1024, 256, 4096, 4096, 16384, 1, 65536, 65536, 262144, 65536, 1048576, 1048576, 4194304, 65536, 16777216, 16777216, 67108864, 16777216, 268435456, 268435456, 1073741824, 1, 4294967296, 4294967296
Offset: 1

Views

Author

Thomas Ward, Mar 08 2001

Keywords

Comments

Number of points of period n in the simplest nontrivial disconnected S-integer dynamical system.
This sequence comes from the simplest disconnected S-integer system that is not hyperbolic. In the terminology of the papers referred to, it is constructed by choosing the under- lying field to be F_2(t), the element to be t and the nontrivial valuation to correspond to the polynomial 1+t. Since it counts periodic points, it satisfies the nontrivial congruence sum_{d|n}mu(d)a(n/d) = 0 mod n for all n and since it comes from a group automorphism it is a divisibility sequence.

Examples

			a(24) = 2^16 = 65536 because ord_2(24)=3, so 24-2^ord_2(24)=16.
		

Crossrefs

Programs

  • Maple
    readlib(ifactors): for n from 1 to 100 do if n mod 2 = 1 then ord2 := 0 else ord2 := ifactors(n)[2][1][2] fi: printf(`%d,`, 2^(n-2^ord2)) od:
  • Mathematica
    ord2[n_?OddQ] = 0; ord2[n_?EvenQ] := FactorInteger[n][[1, 2]]; a[n_] := 2^(n-2^ord2[n]); a /@ Range[34]
    (* Jean-François Alcover, May 19 2011, after Maple prog. *)

Extensions

More terms from James Sellers, Mar 15 2001

A228347 Triangle of regions and compositions of the positive integers (see Comments lines for definition).

Original entry on oeis.org

1, 1, 2, 0, 0, 1, 1, 1, 2, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 1

Views

Author

Omar E. Pol, Aug 26 2013

Keywords

Comments

Triangle read by rows in which row n lists A129760(n) zeros followed by the A006519(n) elements of the row A001511(n) of triangle A090996, n >= 1.
The equivalent sequence for partitions is A186114.

Examples

			----------------------------------------------------------
.             Diagram                Triangle
Compositions    of            of compositions (rows)
of 5          regions          and regions (columns)
----------------------------------------------------------
.            _ _ _ _ _
5           |_        |                                 5
1+4         |_|_      |                               1 4
2+3         |_  |     |                             2 0 3
1+1+3       |_|_|_    |                           1 1 0 3
3+2         |_    |   |                         3 0 0 0 2
1+2+2       |_|_  |   |                       1 2 0 0 0 2
2+1+2       |_  | |   |                     2 0 1 0 0 0 2
1+1+1+2     |_|_|_|_  |                   1 1 0 1 0 0 0 2
4+1         |_      | |                 4 0 0 0 0 0 0 0 1
1+3+1       |_|_    | |               1 3 0 0 0 0 0 0 0 1
2+2+1       |_  |   | |             2 0 2 0 0 0 0 0 0 0 1
1+1+2+1     |_|_|_  | |           1 1 0 2 0 0 0 0 0 0 0 1
3+1+1       |_    | | |         3 0 0 0 1 0 0 0 0 0 0 0 1
1+2+1+1     |_|_  | | |       1 2 0 0 0 1 0 0 0 0 0 0 0 1
2+1+1+1     |_  | | | |     2 0 1 0 0 0 1 0 0 0 0 0 0 0 1
1+1+1+1+1   |_|_|_|_|_|   1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1
.
For the positive integer k consider the first 2^(k-1) rows of triangle, as shown below. The positive terms of the n-th row are the parts of the n-th region of the diagram of regions of the set of compositions of k. The positive terms of the n-th column are the parts of the n-th composition of k, with compositions in colexicographic order.
Triangle begins:
1;
1,2;
0,0,1;
1,1,2,3;
0,0,0,0,1;
0,0,0,0,1,2;
0,0,0,0,0,0,1;
1,1,1,1,2,2,3,4;
0,0,0,0,0,0,0,0,1;
0,0,0,0,0,0,0,0,1,2;
0,0,0,0,0,0,0,0,0,0,1;
0,0,0,0,0,0,0,0,1,1,2,3;
0,0,0,0,0,0,0,0,0,0,0,0,1;
0,0,0,0,0,0,0,0,0,0,0,0,1,2;
0,0,0,0,0,0,0,0,0,0,0,0,0,0,1;
1,1,1,1,1,1,1,1,2,2,2,2,3,3,4,5;
...
		

Crossrefs

Mirror of A228348. Column 1 is A036987. Also column 1 gives A209229, n >= 1. Right border gives A001511. Positive terms give A228349.

A228348 Triangle of regions and compositions of the positive integers (see Comments lines for definition).

Original entry on oeis.org

1, 2, 1, 1, 0, 0, 3, 2, 1, 1, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 4, 3, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0
Offset: 1

Views

Author

Omar E. Pol, Aug 21 2013

Keywords

Comments

Triangle read by rows in which row n lists the A006519(n) elements of the row A001511(n) of triangle A065120 followed by A129760(n) zeros, n >= 1.
The equivalent sequence for integer partitions is A193870.

Examples

			----------------------------------------------------------
.             Diagram                Triangle
Compositions    of            of compositions (rows)
of 5          regions          and regions (columns)
----------------------------------------------------------
.            _ _ _ _ _
5           |_        |                                 5
1+4         |_|_      |                               1 4
2+3         |_  |     |                             2 0 3
1+1+3       |_|_|_    |                           1 1 0 3
3+2         |_    |   |                         3 0 0 0 2
1+2+2       |_|_  |   |                       1 2 0 0 0 2
2+1+2       |_  | |   |                     2 0 1 0 0 0 2
1+1+1+2     |_|_|_|_  |                   1 1 0 1 0 0 0 2
4+1         |_      | |                 4 0 0 0 0 0 0 0 1
1+3+1       |_|_    | |               1 3 0 0 0 0 0 0 0 1
2+2+1       |_  |   | |             2 0 2 0 0 0 0 0 0 0 1
1+1+2+1     |_|_|_  | |           1 1 0 2 0 0 0 0 0 0 0 1
3+1+1       |_    | | |         3 0 0 0 1 0 0 0 0 0 0 0 1
1+2+1+1     |_|_  | | |       1 2 0 0 0 1 0 0 0 0 0 0 0 1
2+1+1+1     |_  | | | |     2 0 1 0 0 0 1 0 0 0 0 0 0 0 1
1+1+1+1+1   |_|_|_|_|_|   1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1
.
For the positive integer k consider the first 2^(k-1) rows of triangle, as shown below. The positive terms of the n-th row are the parts of the n-th region of the diagram of regions of the set of compositions of k. The positive terms of the n-th diagonal are the parts of the n-th composition of k, with compositions in colexicographic order.
Triangle begins:
1;
2,1;
1,0,0;
3,2,1,1;
1,0,0,0,0;
2,1,0,0,0,0;
1,0,0,0,0,0,0;
4,3,2,2,1,1,1,1;
1,0,0,0,0,0,0,0,0;
2,1,0,0,0,0,0,0,0,0;
1,0,0,0,0,0,0,0,0,0,0;
3,2,1,1,0,0,0,0,0,0,0,0;
1,0,0,0,0,0,0,0,0,0,0,0,0;
2,1,0,0,0,0,0,0,0,0,0,0,0,0;
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
5,4,3,3,2,2,2,2,1,1,1,1,1,1,1,1;
...
		

Crossrefs

Mirror of A228347. Column 1 is A001511. Right border gives A036987. Also right border gives A209229, n >= 1. Positive terms give A228350.

A243109 a(n) is the largest number smaller than n and having the same Hamming weight as n, or n if no such number exist.

Original entry on oeis.org

0, 1, 1, 3, 2, 3, 5, 7, 4, 6, 9, 7, 10, 11, 13, 15, 8, 12, 17, 14, 18, 19, 21, 15, 20, 22, 25, 23, 26, 27, 29, 31, 16, 24, 33, 28, 34, 35, 37, 30, 36, 38, 41, 39, 42, 43, 45, 31, 40, 44, 49, 46, 50, 51, 53, 47, 52, 54, 57, 55, 58, 59, 61, 63, 32, 48, 65, 56, 66, 67, 69
Offset: 0

Views

Author

Philippe Beaudoin, Aug 20 2014

Keywords

Comments

To calculate a(n), some bits of n are rearranged. The lowest 1-bit which can move down is the 1 of the lowest 10 bit pair in n. This pair becomes 01 in a(n) and any 1's below there move up to immediately below so the decrease is as small as possible. If n has no 10 bit pair (n = 2^k-1) then nothing smaller is possible and a(n) = n. - Kevin Ryde, Mar 01 2021

Examples

			From _Kevin Ryde_, Mar 01 2021: (Start)
                           v    vv
     n = 1475 = binary 10111000011    lowest 10 of n
  a(n) = 1464 = binary 10110111000    becomes 01 and
                            ^^^       other 1's below
(End)
		

Crossrefs

Cf. A057168 (next of same weight), A066884 (array by weight), A241816 (lowest 10->01).

Programs

  • Mathematica
    A243109[n_] := If[# == 0, n, # - 2^(IntegerExponent[#, 2] - IntegerExponent[n+1, 2] - 1)] & [BitAnd[n, n+1]];
    Array[A243109, 100, 0] (* Paolo Xausa, Mar 07 2025 *)
  • PARI
    a(n) = {my(hn = hammingweight(n)); forstep(k=n-1, 1, -1, if (hammingweight(k) == hn, return (k)); ); return (n); } \\ Michel Marcus, Aug 20 2014
    
  • PARI
    a(n) = my(s=n+1,t=bitand(n,s)); if(t==0,n, t - 1<<(valuation(t,2)-valuation(s,2)-1)); \\ Kevin Ryde, Mar 01 2021
    
  • Python
    def A243109(n): return c if (c:=((~n&(b:=n-(a:=~n&n+1)))>>a.bit_length())^b) else n # Chai Wah Wu, Mar 06 2025

Formula

a(n) = t - 2^(A007814(t) - A007814(n+1) - 1) if t!=0, or a(n) = n if t=0, where t = A129760(n+1) is n with any trailing 1's cleared to 0's and A007814 is the 2-adic valuation. - Kevin Ryde, Mar 01 2021
For k,m > 0, a((2^k-1)*2^m) = 2^(m-1)*(2^(k+1)-3). - Chai Wah Wu, Mar 07 2025
If n is even, then a(n) = XOR(n,OR(a,a/2)) where a = AND(-n,n+1). - Chai Wah Wu, Mar 08 2025

A285097 a(n) = difference between the positions of two least significant 1-bits in base-2 representation of n, or 0 if there are less than two 1-bits in n (when n is either zero or a power of 2).

Original entry on oeis.org

0, 0, 0, 1, 0, 2, 1, 1, 0, 3, 2, 1, 1, 2, 1, 1, 0, 4, 3, 1, 2, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 0, 5, 4, 1, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 1, 1, 1, 4, 3, 1, 2, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 0, 6, 5, 1, 4, 2, 1, 1, 3, 3, 2, 1, 1, 2, 1, 1, 2, 4, 3, 1, 2, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 1, 5, 4, 1, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 1, 1, 1, 4, 3, 1, 2, 2, 1, 1, 1
Offset: 0

Views

Author

Antti Karttunen, Apr 20 2017

Keywords

Comments

a(1+n) is the length of the least significant run of 0-bits in n, or 0 if n is one of terms of A000225. - Antti Karttunen, Oct 14 2023

Examples

			For n = 3, "11" in binary, the second least significant 1-bit (the second 1-bit from the right) is at position 1 and the rightmost 1-bit is at position 0, thus a(3) = 1-0 = 1.
For n = 4, "100" in binary, there is just one 1-bit present, thus a(4) = 0.
For n = 5, "101" in binary, the second 1-bit from the right is at position 2, and the least significant 1 is at position 0, thus a(5) = 2-0 = 2.
For n = 26, "11010" in binary, the second 1-bit from the right is at position 3, and the least significant 1 is at position 1, thus a(26) = 3-1 = 2.
		

Crossrefs

Programs

  • Mathematica
    a007814[n_]:=IntegerExponent[n, 2]; a285099[n_]:=If[DigitCount[n, 2, 1]<2, 0, a007814[BitAnd[n, n - 1]]]; a[n_]:=If[DigitCount[n, 2, 1]<2, 0,a285099[n] - a007814[n]]; Table[a[n], {n, 0, 150}] (* Indranil Ghosh, Apr 20 2017 *)
  • PARI
    A285097(n) = if(!n || !bitand(n,n-1), 0, valuation((n>>valuation(n,2))-1, 2)); \\ Antti Karttunen, Oct 14 2023
  • Python
    import math
    def a007814(n): return int(math.log(n - (n & n - 1), 2))
    def a285099(n): return 0 if bin(n)[2:].count("1") < 2 else a007814(n & (n - 1))
    def a(n): return 0 if bin(n)[2:].count("1")<2 else a285099(n) - a007814(n) # Indranil Ghosh, Apr 20 2017
    
  • Scheme
    (define (A285097 n) (if (<= (A000120 n) 1) 0 (- (A285099 n) (A007814 n))))
    

Formula

If A000120(n) < 2, a(n) = 0, otherwise a(n) = A285099(n) - A007814(n) = A007814(A129760(n)) - A007814(n).
a(n) = 0 if n is 0 or of the form 2^k, (k>=0), otherwise a(n) = v_2(A000265(n)-1), where v_2(i) = A007814(i). - Ridouane Oudra, Oct 20 2019

A334045 Bitwise NOR of binary representation of n and n-1.

Original entry on oeis.org

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
Offset: 1

Views

Author

Christoph Schreier, Apr 13 2020

Keywords

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

Examples

			a(11) = 11 NOR 10 = bin 1011 NOR 1010 = bin 100 = 4.
		

Crossrefs

Cf. A038712 (n XOR n-1), A086799 (n OR n-1), A129760 (n AND n-1).

Programs

  • Maple
    a:= n-> Bits[Nor](n, n-1):
    seq(a(n), n=1..100);  # Alois P. Heinz, Apr 13 2020
  • PARI
    a(n) = my(x=bitor(n-1, n)); bitneg(x, #binary(x)); \\ Michel Marcus, Apr 13 2020
  • 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
    
Previous Showing 11-20 of 29 results. Next