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.

Showing 1-10 of 10 results.

A063694 Remove odd-positioned bits from the binary expansion of n.

Original entry on oeis.org

0, 1, 0, 1, 4, 5, 4, 5, 0, 1, 0, 1, 4, 5, 4, 5, 16, 17, 16, 17, 20, 21, 20, 21, 16, 17, 16, 17, 20, 21, 20, 21, 0, 1, 0, 1, 4, 5, 4, 5, 0, 1, 0, 1, 4, 5, 4, 5, 16, 17, 16, 17, 20, 21, 20, 21, 16, 17, 16, 17, 20, 21, 20, 21, 64, 65, 64, 65, 68, 69, 68, 69, 64, 65, 64, 65, 68, 69, 68
Offset: 0

Views

Author

Antti Karttunen, Aug 03 2001

Keywords

Comments

a(n) is the formal derivative of x*n (evaluated at x=2 after being lifted to Z[x]) where n is interpreted as a polynomial in GF(2)[x] via its binary expansion. - Keith J. Bauer, Mar 17 2024
In the base 4 expansion of n, change 2 to 0 and 3 to 1. - Paolo Xausa, Feb 27 2025

Examples

			a(25) = 17 because 25 = 11001 in binary and when we AND this with 10101 we are left with 10001 = 17.
		

Crossrefs

Cf. A004514, A063695 (remove even-positioned bits), A088442.

Programs

  • Haskell
    a063694 0 = 0
    a063694 n = 4 * a063694 n' + mod q 2
                where (n', q) = divMod n 4
    -- Reinhard Zumkeller, Sep 26 2015
    
  • Magma
    function A063694(n)
      if n le 1 then return n;
      else return 4*A063694(Floor(n/4)) + ((n mod 4) mod 2);
      end if; return A063694;
    end function;
    [A063694(n): n in [0..120]]; // G. C. Greubel, Dec 05 2022
    
  • Maple
    every_other_pos := proc(nn, x, w) local n, i, s; n := nn; i := 0; s := 0; while(n > 0) do if((i mod 2) = w) then s := s + ((x^i)*(n mod x)); fi; n := floor(n/x); i := i+1; od; RETURN(s); end: [seq(every_other_pos(j, 2, 0), j=0..120)];
  • Mathematica
    a[n_] := BitAnd[n, Sum[2^k, {k, 0, Log[2, n] // Floor, 2}]]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Feb 28 2016 *)
    A063694[n_] := FromDigits[ReplaceAll[IntegerDigits[n, 4], {2 -> 0, 3 -> 1}], 4];
    Array[A063694, 100, 0] (* Paolo Xausa, Feb 27 2025 *)
  • PARI
    a(n)=sum(k=0,n,(-1)^k*2^k*floor(n/2^k))  /* since n> ceil(log(n)/log(2)) */
    
  • PARI
    a(n)=if(n<0,0,sum(k=0,n,(-1)^k*2^k*floor(n/2^k))) /* since n> ceil(log(n)/log(2)) */
    
  • Python
    def A063694(n): return n&((1<<(m:=n.bit_length())+(m&1))-1)//3 # Chai Wah Wu, Jan 30 2023
  • SageMath
    def A063694(n):
        if (n<2): return n
        else: return 4*A063694(floor(n/4)) + ((n%4)%2)
    [A063694(n) for n in range(121)] # G. C. Greubel, Dec 05 2022
    

Formula

a(n) = Sum_{k>=0} (-1)^k*2^k*floor(n/2^k).
a(n) + A063695(n) = n.
a(n) = n - 2*a(floor(n/2)). - Vladeta Jovovic, Feb 23 2003
G.f.: 1/(1-x) * Sum_{k>=0} (-2)^k*x^2^k/(1-x^2^k). - Ralf Stephan, May 05 2003
a(n) = 4*a(floor(n/4)) + (n mod 4) mod 2. - Reinhard Zumkeller, Sep 26 2015
a(n) = Sum_{k>=0} A030308(n,k)*A199572(k). - Philippe Deléham, Jan 12 2023

A090569 The survivor w(n,2) in a modified Josephus problem, with a step of 2.

Original entry on oeis.org

1, 1, 3, 3, 1, 1, 3, 3, 9, 9, 11, 11, 9, 9, 11, 11, 1, 1, 3, 3, 1, 1, 3, 3, 9, 9, 11, 11, 9, 9, 11, 11, 33, 33, 35, 35, 33, 33, 35, 35, 41, 41, 43, 43, 41, 41, 43, 43, 33, 33, 35, 35, 33, 33, 35, 35, 41, 41, 43, 43, 41, 41, 43, 43, 1, 1, 3, 3, 1, 1, 3, 3, 9, 9, 11, 11, 9, 9, 11, 11, 1, 1
Offset: 1

Views

Author

John W. Layman, Dec 02 2003

Keywords

Comments

Arrange n persons {1,2,...,n} consecutively on a line rather than around in a circle. Beginning at the left end of the line, we remove every q-th person until we reach the end of the line. At this point we immediately reverse directions, taking care not to "double count" the person at the end of the line and continue to eliminate every q-th person, but now moving right to left. We continue removing people in this back-and-forth manner until there remains a lone survivor w(n,q).
Or a(n) is in A145812 such that 2n+1-2a(n) is in A145812 as well. Note also that 2a(n)+A088442(n-1)=2n+1. - Vladimir Shevelev, Oct 20 2008

Examples

			a(2)=11, since people are eliminated in the order 2, 4, 6, 8, 10, 12, 9, 5, 1, 7, 3, leaving 11 as the survivor.
		

Crossrefs

Programs

  • Python
    def A090569(n): return (n-1&((1<<(m:=(n-1).bit_length())+(m&1^1))-1)//3)+1 # Chai Wah Wu, Jan 30 2023

Formula

w(n, 2) = 1 + Sum_{odd j=1..k} b(j)*(2^j), where Sum_{j=0..k} b(j)*(2^j) is the binary expansion of either n or n-1, whichever is odd.
a(n) = A063695(n-1) + 1.

A366245 The largest infinitary divisor of n that is a term of A366243.

Original entry on oeis.org

1, 1, 1, 4, 1, 1, 1, 4, 9, 1, 1, 4, 1, 1, 1, 1, 1, 9, 1, 4, 1, 1, 1, 4, 25, 1, 9, 4, 1, 1, 1, 1, 1, 1, 1, 36, 1, 1, 1, 4, 1, 1, 1, 4, 9, 1, 1, 1, 49, 25, 1, 4, 1, 9, 1, 4, 1, 1, 1, 4, 1, 1, 9, 4, 1, 1, 1, 4, 1, 1, 1, 36, 1, 1, 25, 4, 1, 1, 1, 1, 1, 1, 1, 4, 1
Offset: 1

Views

Author

Amiram Eldar, Oct 05 2023

Keywords

Comments

First differs from A335324 at n = 256.

Crossrefs

See the formula section for the relationships with A008833, A046100, A059895, A059896, A059897, A225546, A248101, A352780.

Programs

  • Mathematica
    f[p_, e_] := p^BitAnd[e, Sum[2^k, {k, 1, Floor@ Log2[e], 2}]]; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100]
  • PARI
    s(e) = -sum(k = 1, e, (-2)^k*floor(e/2^k));
    a(n) = {my(f = factor(n)); prod(i = 1, #f~, f[i,1]^s(f[i,2]));}

Formula

Multiplicative with a(p^e) = p^A063695(e).
a(n) = n / A366244(n).
a(n) >= 1, with equality if and only if n is a term of A366242.
a(n) <= n, with equality if and only if n is a term of A366243.
From Peter Munn, Jan 09 2025: (Start)
a(n) = max({k in A366243 : A059895(k, n) = k}).
a(n) = Product_{k >= 0} A352780(n, 2k+1).
Also defined by:
- for n in A046100, a(n) = A008833(n);
- a(n^4) = (a(n))^4;
- a(A059896(n,k)) = A059896(a(n), a(k)).
Other identities:
a(n) = sqrt(A366244(n^2)).
a(A059897(n,k)) = A059897(a(n), a(k)).
a(A225546(n)) = A225546(A248101(n)).
(End)

A004514 Generalized nim sum n + n in base 4.

Original entry on oeis.org

0, 2, 0, 2, 8, 10, 8, 10, 0, 2, 0, 2, 8, 10, 8, 10, 32, 34, 32, 34, 40, 42, 40, 42, 32, 34, 32, 34, 40, 42, 40, 42, 0, 2, 0, 2, 8, 10, 8, 10, 0, 2, 0, 2, 8, 10, 8, 10, 32, 34, 32, 34, 40, 42, 40, 42, 32, 34, 32, 34, 40, 42, 40, 42, 128, 130, 128, 130, 136, 138, 136, 138, 128
Offset: 0

Views

Author

Keywords

Comments

In the base 4 expansion of 2*n + 1, change 1 to 0 and 3 to 2. - Paolo Xausa, Feb 27 2025

Crossrefs

Programs

Formula

Generalized nim sum m + n in base q: write m and n in base q and add mod q with no carries, e.g., 5 + 8 in base 3 = "21" + "22" = "10" = 1.
From Vladeta Jovovic, Feb 23 2003: (Start)
a(n) = 2*(n - a(floor(n/2))).
a(n) = 2*A063694(n). (End)
a(n) = A088442(n) - 1. - Chris Groer (cgroer(AT)math.uga.edu), Nov 10 2003
a(n) = n + A053985(n). - Reinhard Zumkeller, Dec 27 2003
a(n) = A063695(2*n+1). - Reinhard Zumkeller, Sep 26 2015
a(n) = Sum_{k>=0} A030308(n,k)*A103424(k+1). - Philippe Deléham, Jan 12 2023

Extensions

More terms from Reinhard Zumkeller, Dec 27 2003

A345290 a(n) is obtained by replacing 2^k in binary expansion of n with Fibonacci(-k-2).

Original entry on oeis.org

0, -1, 2, 1, -3, -4, -1, -2, 5, 4, 7, 6, 2, 1, 4, 3, -8, -9, -6, -7, -11, -12, -9, -10, -3, -4, -1, -2, -6, -7, -4, -5, 13, 12, 15, 14, 10, 9, 12, 11, 18, 17, 20, 19, 15, 14, 17, 16, 5, 4, 7, 6, 2, 1, 4, 3, 10, 9, 12, 11, 7, 6, 9, 8, -21, -22, -19, -20, -24
Offset: 0

Views

Author

Rémy Sigrist, Jun 13 2021

Keywords

Comments

This sequence is a variant of A022290; here we consider Fibonacci numbers with negative indices (A039834), there Fibonacci numbers with positive indices (A000045).
After the initial 0, the sequence alternates runs of positive terms and runs of negative terms, the k-th run having 2^(k-1) terms.

Examples

			For n = 3:
- 3 = 2^1 + 2^0,
- so a(3) = A039834(2+1) + A039834(2+0) = 2 - 1 = 1.
		

Crossrefs

Programs

  • PARI
    a(n) = { my (v=0, e); while (n, n-=2^e=valuation(n, 2); v+=fibonacci(-2-e)); v }

Formula

a(n) = A022290(A063695(n)) - A022290(A063694(n)).
a(n) = A022290(n) iff n belongs to A062880.
a(n) = -A022290(n) iff n belongs to A000695.
a(n) = 0 iff n = 0.
a(n) = 1 iff n belongs to A072197.
a(n) = 2 iff n belongs to A080675.
a(n) = -1 iff n belongs to A020989.
a(n) = -2 iff n belongs to A136412.

A371459 For any positive integer with binary digits (b_1, ..., b_w) (where b_1 = 1), the binary digits of a(n), possibly with leading zeros, are (b_2, b_4, ..., b_{floor(w/2) * 2}); a(0) = 0.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Mar 24 2024

Keywords

Comments

In other words, we keep even-indexed bits.
Every integer appears infinitely many times in the sequence.

Examples

			The first terms, in decimal and in binary, are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     0       1          0
   2     0      10          0
   3     1      11          1
   4     0     100          0
   5     0     101          0
   6     1     110          1
   7     1     111          1
   8     0    1000          0
   9     1    1001          1
  10     0    1010          0
  11     1    1011          1
  12     2    1100         10
  13     3    1101         11
  14     2    1110         10
  15     3    1111         11
  16     0   10000          0
		

Crossrefs

See A371442 for the sequence related to odd-indexed bits.
See A059906 and A063695 for similar sequences.

Programs

  • Mathematica
    A371459[n_] := FromDigits[IntegerDigits[n, 2][[2;;-1;;2]], 2];
    Array[A371459, 100, 0] (* Paolo Xausa, Mar 28 2024 *)
  • PARI
    a(n) = { my (b = binary(n)); fromdigits(vector(#b\2, k, b[2*k]), 2); }
    
  • Python
    def A371459(n): return int(bin(n)[3::2],2) if n>1 else 0 # Chai Wah Wu, Mar 27 2024

Formula

a(n) = 0 iff n belongs to A126684.
a(A000695(n)) = 0.
a(A001196(n)) = n.

A377414 a(n) is the largest term of A126684, say b, such that n AND b = b (where AND denotes the bitwise AND operator).

Original entry on oeis.org

0, 1, 2, 2, 4, 5, 4, 5, 8, 8, 10, 10, 8, 8, 10, 10, 16, 17, 16, 17, 20, 21, 20, 21, 16, 17, 16, 17, 20, 21, 20, 21, 32, 32, 34, 34, 32, 32, 34, 34, 40, 40, 42, 42, 40, 40, 42, 42, 32, 32, 34, 34, 32, 32, 34, 34, 40, 40, 42, 42, 40, 40, 42, 42, 64, 65, 64, 65
Offset: 0

Views

Author

Rémy Sigrist, Oct 27 2024

Keywords

Comments

For any n > 0 with binary expansion (b_1 = 1, b_2, ..., b_k), the binary expansion of a(n) is (c_1, ..., c_k) where c_i = b_i when i is odd, c_i = 0 when i is even.
For any n, the value c = n - a(n) also belongs to A126684 and satisfies n AND c = c (see A377415).

Examples

			The first terms, in decimal and in binary, are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     2      10         10
   3     2      11         10
   4     4     100        100
   5     5     101        101
   6     4     110        100
   7     5     111        101
   8     8    1000       1000
   9     8    1001       1000
  10    10    1010       1010
  11    10    1011       1010
  12     8    1100       1000
  13     8    1101       1000
  14    10    1110       1010
  15    10    1111       1010
		

Crossrefs

See A063694, A063695 and A374356 for similar sequences.

Programs

  • PARI
    a(n) = { my (v = 0, x = exponent(n), y); while (n, n -= 2^y = exponent(n); if (x%2 == y%2, v += 2^y;);); return (v); }

Formula

a(n) <= n with equality iff n belongs to A126684.
a(a(n)) = a(n).
a(2*n) = 2*a(n).
a(n) = n AND A000975(A070939(n)). - Alan Michael Gómez Calderón, Jun 27 2025

A377415 a(n) = n - A377414(n).

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 2, 2, 0, 1, 0, 1, 4, 5, 4, 5, 0, 0, 2, 2, 0, 0, 2, 2, 8, 8, 10, 10, 8, 8, 10, 10, 0, 1, 0, 1, 4, 5, 4, 5, 0, 1, 0, 1, 4, 5, 4, 5, 16, 17, 16, 17, 20, 21, 20, 21, 16, 17, 16, 17, 20, 21, 20, 21, 0, 0, 2, 2, 0, 0, 2, 2, 8, 8, 10, 10, 8, 8, 10
Offset: 0

Views

Author

Rémy Sigrist, Oct 27 2024

Keywords

Comments

For any n > 0 with binary expansion (b_1 = 1, b_2, ..., b_k), the binary expansion of a(n) is (c_1, ..., c_k) where c_i = b_i when i is even, c_i = 0 when i is odd.

Examples

			The first terms, in decimal and in binary, are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     0       1          0
   2     0      10          0
   3     1      11          1
   4     0     100          0
   5     0     101          0
   6     2     110         10
   7     2     111         10
   8     0    1000          0
   9     1    1001          1
  10     0    1010          0
  11     1    1011          1
  12     4    1100        100
  13     5    1101        101
  14     4    1110        100
  15     5    1111        101
		

Crossrefs

See A063694, A063695 and A374355 for similar sequences.

Programs

  • PARI
    a(n) = { my (v = 0, x = exponent(n), y); while (n, n -= 2^y = exponent(n); if (x%2 != y%2, v += 2^y;);); return (v); }

Formula

a(n) = 0 iff n belongs to A126684.
a(a(n)) = 0.
a(2*n) = 2*a(n).

A380110 In the base 4 expansion of n: map 0->0, 1->1, 2->1, 3->2.

Original entry on oeis.org

0, 1, 1, 2, 4, 5, 5, 6, 4, 5, 5, 6, 8, 9, 9, 10, 16, 17, 17, 18, 20, 21, 21, 22, 20, 21, 21, 22, 24, 25, 25, 26, 16, 17, 17, 18, 20, 21, 21, 22, 20, 21, 21, 22, 24, 25, 25, 26, 32, 33, 33, 34, 36, 37, 37, 38, 36, 37, 37, 38, 40, 41, 41, 42, 64, 65, 65, 66, 68, 69
Offset: 0

Views

Author

Darío Clavijo, Feb 14 2025

Keywords

Comments

This is essentialy the mapping of the half adder where the inputs A,B maps to outputs: C_out and S as in binary: 00->00, 01->01, 10->01, 11->10, where C_out is the carry out bit and S is the sum bit.
The fixed points for this sequence are in the Moser-de Bruijn sequence (A000695).

Examples

			Half adder truth table:
 A | B | C_out | S
---+---+-------+------
 0 | 0 | 0     | 0
 0 | 1 | 0     | 1
 1 | 0 | 0     | 1
 1 | 1 | 1     | 0
For n = 25 a(25) = 21 because:
25 = 121_4 and 121_4 maps to 111_4 which is 21.
		

Crossrefs

Programs

  • Mathematica
    A380110[n_] := FromDigits[ReplaceAll[IntegerDigits[n, 4], {2 -> 1, 3 -> 2}], 4];
    Array[A380110, 100, 0] (* Paolo Xausa, Feb 27 2025 *)
  • Python
    def a(n):
        r,p = 0,1
        while n:
            ps = (n & 1) + ((n >> 1) & 1)
            r += ps * p
            n >>= 2
            p <<= 2
        return r
    print([a(n) for n in range(70)])

Formula

a(n) = n iff n in A000695.
a(2^k) = A213173(n).
a(n) = a(n-1)+1 if n odd.
a(n) = n-A063695(n)/2.

A335552 Triangle T(n,k) read by rows: in the Josephus problem with n initial numbers on a line: eliminate each second and reverse left-right-direction of elimination. T(n,k) is the (n-k+1)st element removed, 1<=k<=n.

Original entry on oeis.org

1, 3, 1, 3, 1, 4, 1, 5, 3, 4, 1, 5, 3, 6, 4, 3, 7, 1, 5, 6, 4, 3, 7, 1, 5, 8, 6, 4, 9, 1, 5, 3, 7, 8, 6, 4, 9, 1, 5, 3, 7, 10, 8, 6, 4, 11, 3, 7, 1, 5, 9, 10, 8, 6, 4, 11, 3, 7, 1, 5, 9, 12, 10, 8, 6, 4, 9, 1, 13, 5, 3, 7, 11, 12, 10, 8, 6, 4, 9, 1, 13, 5, 3, 7, 11, 14, 12, 10, 8, 6, 4, 11, 3, 15
Offset: 1

Views

Author

R. J. Mathar, Jun 22 2020

Keywords

Examples

			The triangle starts
   1
   3   1
   3   1   4
   1   5   3   4
   1   5   3   6   4
   3   7   1   5   6   4
   3   7   1   5   8   6   4
   9   1   5   3   7   8   6   4
   9   1   5   3   7  10   8   6   4
  11   3   7   1   5   9  10   8   6   4
  11   3   7   1   5   9  12  10   8   6   4
   9   1  13   5   3   7  11  12  10   8   6   4
   9   1  13   5   3   7  11  14  12  10   8   6   4
  11   3  15   7   1   5   9  13  14  12  10   8   6   4
  11   3  15   7   1   5   9  13  16  14  12  10   8   6   4
   1  17   9  13   5   3   7  11  15  16  14  12  10   8   6   4
   1  17   9  13   5   3   7  11  15  18  16  14  12  10   8   6   4
   3  19  11  15   7   1   5   9  13  17  18  16  14  12  10   8   6   4
   3  19  11  15   7   1   5   9  13  17  20  18  16  14  12  10   8   6   4
		

Crossrefs

Cf. A090569 (column k=1).

Programs

  • Maple
    sigr := proc(n,r)
        floor(n/2^r) ;
    end proc:
    # A063695
    f := proc(n)
        local ndigs,fn,k ;
        ndigs := convert(n,base,2) ;
        fn := 0 ;
        for k from 2 to nops(ndigs) by 2 do
            fn := fn+op(k,ndigs)*2^(k-1)
        end do;
        fn ;
    end proc:
    g := proc(t,n)
        local r;
        if t =1 then
            0 ;
        elif t > 1 then
            r := ilog2( (n-1)/(t-1) ) ;
            (-2)^r*(f( sigr(2*n-1,r) )+f( sigr(n-1,r) )-2*t+3) ;
        end if;
    end proc:
    ft := proc(t,n)
        f(n-1)+1+g(t,n) ;
    end proc:
    for n from 1 to 20 do
        for t from 1 to n-1 do
            printf("%3d ", ft(t,n)) ;
        end do:
        printf("\n") ;
    end do:
Showing 1-10 of 10 results.