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 11 results. Next

A092570 Primes p which become a prime q under transformation of inner bits of binary representation in A092569. In binary representation of p, transformation of inner bits, 1 <-> 0, gives binary representation of q.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 29, 31, 37, 43, 53, 59, 79, 83, 89, 103, 109, 113, 151, 157, 173, 191, 193, 211, 227, 233, 269, 277, 281, 307, 311, 337, 347, 349, 359, 367, 379, 389, 401, 409, 419, 421, 431, 457, 461, 487, 491, 499, 523, 569, 599, 607, 617, 653, 659
Offset: 1

Views

Author

Zak Seidov, Feb 28 2004

Keywords

Examples

			307 and 461 are terms because 307_10 = 100110011_2, transformation of inner bits gives 100110011_2 -> 111001101_2 = 461_10.
		

Crossrefs

Cf. A092569.

Programs

  • Mathematica
    ptibQ[n_]:=Module[{id=IntegerDigits[n,2],f,l,r},f=id[[1]];l=id[[-1]];r=Most[Rest[id]];PrimeQ[FromDigits[Join[{f},r/.{1->0,0->1},{l}],2]]]; Select[Prime[Range[200]],ptibQ] (* Harvey P. Dale, Jul 16 2025 *)
  • PARI
    T(p)={pow2=2;v=binary(p);L=#v-1;forstep(k=L,2,-1,if(v[k],p-=pow2,p+=pow2);pow2*=2);return(p)};
    forprime(p=2,659,if(isprime(T(p)),print1(p,", ")))
    \\ Washington Bomfim, Jan 18 2011

A284447 Permutation of the positive integers: a(n) = A258996(A092569(n)) = A092569(A258996(n)).

Original entry on oeis.org

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

Views

Author

Yosu Yurramendi, Apr 06 2017

Keywords

Comments

The permutation is self-inverse. Except for fixed points 1, 2, 3, 4, 5, 6, 7 it consists completely of 2-cycles: (8,12), (9,13), (10,14), (11,15), (16,20), (17,21), (18,22), (19,23), (24,28), (25,29), (26,30), (27,31), (32,52), (33,53), (34,54), (35,55), (36,48), (37,49), (38,50), (39,51), (40,60), ...
{A000027, A258996, A092569, a = A258996(A092569)} form a Klein 4-group.

Crossrefs

Analogous to A284120. Similar R-programs: A258996, A332769.

Programs

  • R
    maxrow <- 8 # by choice
    a <- 1:3
    for(m in 1:maxrow) for(k in 0:(2^m-1)){
    if(m%%2 == 1){a[2^(m+1)+    k] <- a[2^m+k] + 2^m
                  a[2^(m+1)+2^m+k] <- a[2^m+k] + 2^(m+1)}
    else         {a[2^(m+1)+    k] <- a[2^m+k] + 2^(m+1)
                  a[2^(m+1)+2^m+k] <- a[2^m+k] + 2^m}
    }
    a
    # Yosu Yurramendi, Apr 06 2017
    
  • R
    # Given n, compute a(n) by taking into account the binary representation of n
    maxblock <- 7 # by choice
    a <- 1:7
    for(n in 8:2^maxblock){
      ones <- which(as.integer(intToBits(n)) == 1)
      nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
      anbit <- nbit
      anbit[seq(3, length(anbit) - 1, 2)] <- 1 - anbit[seq(3, length(anbit) - 1, 2)]
      a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
    }
    a
    # Yosu Yurramendi, Mar 30 2021

A054429 Simple self-inverse permutation of natural numbers: List each block of 2^n numbers (from 2^n to 2^(n+1) - 1) in reverse order.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

a(n) gives the position of the inverse of the n-th term in the full Stern-Brocot tree: A007305(a(n)+2) = A047679(n) and A047679(a(n)) = A007305(n+2). - Reinhard Zumkeller, Dec 22 2008
From Gary W. Adamson, Jun 21 2012: (Start)
The mapping and conversion rules are as follows:
By rows, we have ...
1;
3, 2;
7, 6, 5, 4;
15, 14, 13, 12, 11, 10, 9, 8;
... onto which we are to map one-half of the Stern-Brocot infinite Farey Tree:
1/2
1/3, 2/3
1/4, 2/5, 3/5, 3/4
1/5, 2/7, 3/8, 3/7, 4/7, 5/8, 5/7, 4/5
...
The conversion rules are: Convert the decimal to binary, adding a duplicate of the rightmost binary term to its right. For example, 10 = 1010, which becomes 10100. Then, from the left, record the number of runs = [1,1,1,2], the continued fraction representation of 5/8. Check: 10 decimal corresponds to 5/8 as shown in the overlaid mapping. Take decimal 9 = 1001 which becomes 10011, with a continued fraction representation of [1,2,2] = 5/7. Check: 9 decimal corresponds to 5/7 in the Farey Tree map. (End)
From Indranil Ghosh, Jan 19 2017: (Start)
a(n) is the value generated when n is converted into its Elias gamma code, the 1's and 0's are interchanged and the resultant is converted back to its decimal value for all values of n > 1. For n = 1, A054429(n) = 1 but after converting 1 to Elias gamma code, interchanging the 1's and 0's and converting it back to decimal, the result produced is 0.
For example, let n = 10. The Elias gamma code for 10 is '1110010'. After interchanging the 1's and 0's it becomes "0001101" and 1101_2 = 13_10. So a(10) = 13. (End)
From Yosu Yurramendi, Mar 09 2017 (similar to Zumkeller's comment): (Start)
A002487(a(n)) = A002487(n+1), A002487(a(n)+1) = A002487(n), n > 0.
A162909(a(n)) = A162910(n), A162910(a(n)) = A162909(n), n > 0.
A162911(a(n)) = A162912(n), A162912(a(n)) = A162911(n), n > 0.
A071766(a(n)) = A245326(n), A245326(a(n)) = A071766(n), n > 0.
A229742(a(n)) = A245325(n), A245325(a(n)) = A229742(n), n > 0.
A020651(a(n)) = A245327(n), A245327(a(n)) = A020651(n), n > 0.
A020650(a(n)) = A245328(n), A245328(a(n)) = A020650(n), n > 0. (End)
From Yosu Yurramendi, Mar 29 2017: (Start)
A063946(a(n)) = a(A063946(n)) = A117120(n), n > 0.
A065190(a(n)) = a(A065190(n)) = A092569(n), n > 0.
A258746(a(n)) = a(A258746(n)) = A165199(n), n > 0.
A258996(a(n)) = a(A258996(n)), n > 0.
A117120(a(n)) = a(A117120(n)), n > 0.
A092569(a(n)) = a(A092569(n)), n > 0. (End)

Crossrefs

See also A054424, A054430.
{A000027, A054429, A059893, A059894} form a 4-group.
This is Guy Steele's sequence GS(6, 5) (see A135416).

Programs

  • Haskell
    a054429 n = a054429_list !! (n-1)
    a054429_list = f [1..] where
       f xs@(x:_) = reverse us ++ f vs where (us, vs) = splitAt x xs
    -- Reinhard Zumkeller, Jun 01 2015, Feb 21 2014
    
  • Maple
    A054429 := n -> 3*2^ilog2(n) - n - 1:
    seq(A054429(n), n = 1..70); # [Updated by Peter Luschny, Apr 24 2024]
  • Mathematica
    Flatten[Table[Range[2^(n+1)-1,2^n,-1],{n,0,6}]] (* Harvey P. Dale, Dec 17 2013 *)
  • PARI
    A054429(n)= 3<<#binary(n\2)-n-1 \\ M. F. Hasler, Aug 18 2014
    
  • Python
    from itertools import count, islice
    def A054429_gen(): # generator of terms
        return (m for n in count(0) for m in range((1<A054429_list = list(islice(A054429_gen(),30)) # Chai Wah Wu, Jul 27 2023
  • R
    maxblock <- 10 # by choice
    a <- NULL
    for(m in 0:maxblock) a <- c(a, rev(2^m:(2^(m+1)-1)))
    a
    # Yosu Yurramendi, Mar 10 2017
    

Formula

a(n) = ReflectBinTreePermutation(n).
a(n) = if n=1 then 1 else 2*a(floor(n/2)) + 1 - n mod 2. - Reinhard Zumkeller, Feb 18 2003
G.f.: 1/(1-x) * ((x-2x^2)/(1-x) + Sum_{k>=0} 3*2^k*x^2^k). - Ralf Stephan, Sep 15 2003
A000120(a(n)) = A000120(A059894(n)) = A023416(n) + 1. - Ralf Stephan, Oct 05 2003
A115310(n, 1) = a(n). - Reinhard Zumkeller, Jan 20 2006
a(1) = 1, a(2^(m+1) + k) = a(2^m+k) + 2^(m+1),
a(2^(m+1) + 2^m+k) = a(2^m+k) + 2^m, m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Apr 06 2017
a(n) = A117120(A063946(n)) = A063946(A117120(n)) = A092569(A065190(n)) = A065190(A092569(n)), n > 0. - Yosu Yurramendi, Apr 10 2017
a(n) = 3*A053644(n) - n - 1. - Alan Michael Gómez Calderón, Feb 28 2025

A065190 Self-inverse permutation of the positive integers: 1 is fixed, followed by an infinite number of adjacent transpositions (n n+1).

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Oct 19 2001

Keywords

Comments

Also, a lexicographically minimal sequence of distinct positive integers such that a(n) is coprime to n. - Ivan Neretin, Apr 18 2015
The larger term of the pair (a(n), a(n+1)) is always odd. Had we started the sequence with a(1) = 0, it would be the lexicographically first sequence with this property if always extented with the smallest integer not yet present. - Eric Angelini, Feb 17 2017
From Yosu Yurramendi, Mar 21 2017: (Start)
This sequence is self-inverse. Except for the fixed point 1, it consists completely of 2-cycles: (2n, 2n+1), n > 0.
A020651(a(n)) = A020650(n), A020650(a(n)) = A020651(n), n > 0.
A245327(a(n)) = A245328(n), A245328(a(n)) = A245327(n), n > 0.
A063946(a(n)) = a(A063946(n)), n > 0.
A054429(a(n)) = a(A054429(n)) = A092569(n), n > 0.
A258996(a(n)) = a(A258996(n)), n > 0.
A258746(a(n)) = a(A258746(n)), n > 0. (End)
From Enrique Navarrete, Nov 13 2017: (Start)
With a(0)=0, and the rest of the sequence appended, a(n) is the smallest positive number not yet in the sequence such that the arithmetic mean of the first n+1 terms a(0), a(1), ..., a(n) is not an integer; i.e., the sequence is 0, 1, 3, 2, 5, 4, 7, 6, 9, 8, ...
Example: for n=5, (0 + 1 + 3 + 2 + 5)/5 is not an integer.
Fixed points are odd numbers >= 3 and also a(n) = n-2 for even n >= 4. (End)

Crossrefs

Programs

  • Magma
    [1] cat [n+(-1)^n: n in [2..80]]; // Vincenzo Librandi, Apr 18 2015
    
  • Maple
    [seq(f(j),j=1..120)]; f := (n) -> `if`((n < 2), n,n+((-1)^n));
  • Mathematica
    f[n_] := Rest@ Flatten@ Transpose[{Range[1, n + 1, 2], {1}~Join~Range[2, n, 2]}]; f@ 72 (* Michael De Vlieger, Apr 18 2015 *)
    Rest@ CoefficientList[Series[x (x^3 - 2 x^2 + 2 x + 1)/((x - 1)^2*(x + 1)), {x, 0, 72}], x] (* Michael De Vlieger, Feb 17 2017 *)
    Join[{1},LinearRecurrence[{1,1,-1},{3,2,5},80]] (* Harvey P. Dale, Feb 24 2021 *)
  • PARI
    { for (n=1, 1000, if (n>1, a=n + (-1)^n, a=1); write("b065190.txt", n, " ", a) ) } \\ Harry J. Smith, Oct 13 2009
    
  • PARI
    x='x+O('x^100); Vec(x*(x^3-2*x^2+2*x+1)/((x-1)^2*(x+1))) \\ Altug Alkan, Feb 04 2016
    
  • Python
    def a(n): return 1 if n<2 else n + (-1)**n # Indranil Ghosh, Mar 22 2017
    
  • R
    maxrow <- 8 # by choice
    a <- c(1,3,2) # If it were c(1,2,3), it would be A000027
      for(m in 1:maxrow) for(k in 0:(2^m-1)){
    a[2^(m+1)+    k] = a[2^m+k] + 2^m
    a[2^(m+1)+2^m+k] = a[2^m+k] + 2^(m+1)
    }
    a
    # Yosu Yurramendi, Apr 10 2017

Formula

a(1) = 1, a(n) = n+(-1)^n.
From Colin Barker, Feb 18 2013: (Start)
a(n) = a(n-1) + a(n-2) - a(n-3) for n>4.
G.f.: x*(x^3 - 2*x^2 + 2*x + 1) / ((x-1)^2*(x+1)). (End)
a(n)^a(n) == 1 (mod n). - Thomas Ordowski, Jan 04 2016
E.g.f.: x*(1+exp(x)) - 1 + exp(-x). - Robert Israel, Feb 04 2016
a(n) = A014681(n-1) + 1. - Michel Marcus, Dec 10 2016
a(1) = 1, for n > 0 a(2*n) = 2*a(a(n)) + 1, a(2*n + 1) = 2*a(a(n)). - Yosu Yurramendi, Dec 12 2020

A258996 Permutation of the positive integers: this permutation transforms the enumeration system of positive irreducible fractions A002487/A002487' (Calkin-Wilf) into the enumeration system A162911/A162912 (Drib), and vice versa.

Original entry on oeis.org

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

Views

Author

Yosu Yurramendi, Jun 16 2015

Keywords

Comments

As A258746 the permutation is self-inverse. Except for fixed points 1, 2, 3 it consists completely of 2-cycles: (4,6), (5,7), (8,10), (9,11), (12,14), (13,15), (16,26), (17,27), ..., (21,31), ..., (32,42), ... . - Yosu Yurramendi, Mar 31 2016
When terms of sequence |n - a(n)|/2 (n > 3) are considered only once, and they are sorted in increasing order, A147992 is obtained. - Yosu Yurramendi, Apr 05 2016

Crossrefs

Cf. A092569, A117120, A258746. Similar R-programs: A332769, A284447.

Programs

  • R
    maxlevel <- 5 # by choice
    a <- 1
    for(m in 0:maxlevel) for(k in 0:(2^m-1)){
      a[2^(m+1) + 2*k    ] = 2*a[2^(m+1) - 1 - k]
      a[2^(m+1) + 2*k + 1] = 2*a[2^(m+1) - 1 - k] + 1}
    a
    
  • R
    # Given n, compute a(n) by taking into account the binary representation of n
    maxblock <- 7 # by choice
    a <- 1:3
    for(n in 4:2^maxblock){
      ones <- which(as.integer(intToBits(n)) == 1)
      nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
      anbit <- nbit
      anbit[seq(2, length(anbit) - 1, 2)] <- 1 - anbit[seq(2, length(anbit) - 1, 2)]
      a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
    }
    a
    # Yosu Yurramendi, Mar 30 2021

Formula

a(1) = 1, a(2) = 2, a(3) = 3. For n = 2^m + k, m > 1, 0 <= k < 2^m. If m is even, then a(2^(m+1)+k) = a(2^m + k) + 2^m and a(2^(m+1) + 2^m+k) = a(2^m+k) + 2^(m+1). If m is odd, then a(2^(m+1) + k) = a(2^m+k) + 2^(m+1) and a(2^(m+1) + 2^m+k) = a(2^m+k) + 2^m.
From Yosu Yurramendi, Mar 23 2017: (Start)
A258746(a(n)) = a(A258746(n)), n > 0.
A092569(a(n)) = a(A092569(n)), n > 0.
A117120(a(n)) = a(A117120(n)), n > 0;
A065190(a(n)) = a(A065190(n)), n > 0;
A054429(a(n)) = a(A054429(n)), n > 0;
A063946(a(n)) = a(A063946(n)), n > 0. (End)
a(1) = 1, for m >= 0 and 0 <= k < 2^m, a(2^(m+1) + 2*k) = 2*a(2^(m+1) - 1 - k), a(2^(m+1) + 2*k + 1) = 2*a(2^(m+1) - 1 - k) + 1. - Yosu Yurramendi, May 23 2020
a(n) = A020988(A102572(n)) XOR n. - Alan Michael Gómez Calderón, Mar 11 2025

A258746 Permutation of the positive integers: this permutation transforms the enumeration system of positive irreducible fractions A007305/A047679 (Stern-Brocot) into the enumeration system A162909/A162910 (Bird), and vice versa.

Original entry on oeis.org

1, 2, 3, 5, 4, 7, 6, 10, 11, 8, 9, 14, 15, 12, 13, 21, 20, 23, 22, 17, 16, 19, 18, 29, 28, 31, 30, 25, 24, 27, 26, 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, 58, 59, 56, 57, 62
Offset: 1

Views

Author

Yosu Yurramendi, Jun 09 2015

Keywords

Comments

As A117120 the permutation is self-inverse. Except for fixed points 1, 2, 3 it consists completely of 2-cycles: (4,5), (6,7), (8,10), (9,11), (12,14), (13,15), (16,21), (17,20), ..., (24,29), ..., (32,42), ... .

Crossrefs

Cf. A117120.

Programs

  • R
    a <- 1:3
    maxn <- 50 # by choice
    #
    for(n in 2:maxn){
      m <- floor(log2(n))
      if(m%%2 == 0) {
        a[2*n  ] <- 2*a[n]
        a[2*n+1] <- 2*a[n]+1 }
      else {
        a[2*n  ] <- 2*a[n]+1
        a[2*n+1] <- 2*a[n]   }
    }
    #
    a
    # Yosu Yurramendi, Jun 09 2015
    
  • R
    # Given n, compute a(n) by taking into account the binary representation of n
    maxblock <- 7 # by choice
    a <- 1:3
    for(n in 4:2^maxblock){
      ones <- which(as.integer(intToBits(n)) == 1)
    nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
    anbit <- nbit
    ifelse(floor(log2(n)) %% 2 == 0,
       anbit[seq(1, length(anbit)-1, 2)] <- 1 - anbit[seq(1, length(anbit)-1, 2)],
       anbit[seq(2, length(anbit) - 1, 2)] <- 1 - anbit[seq(2, length(anbit)-1, 2)])
    a <- c(a, sum(anbit*2^(0:(length(anbit)-1))))
    }
    a
    # Yosu Yurramendi, May 29 2021

Formula

a(1) = 1, a(2) = 2, a(3) = 3. For n >= 2, m = floor(log_2(n)). If m even, then a(2*n) = 2*a(n) and a(2*n+1) = 2*a(n)+1. If m odd, then a(2*n) = 2*a(n)+1 and a(2*n+1) = 2*a(n).
From Yosu Yurramendi, Mar 23 2017: (Start)
A258996(a(n)) = a(A258996(n)) for n > 0;
A117120(a(n)) = a(A117120(n)) for n > 0;
A092569(a(n)) = a(A092569(n)) for n > 0;
A063946(a(n)) = a(A063946(n)) for n > 0;
A054429(a(n)) = a(A054429(n)) = A165199(n) for n > 0;
A065190(a(n)) = a(A065190(n)) for n > 0. (End)
a(n) = A054429(A165199(n)). - Alan Michael Gómez Calderón, Mar 08 2025

A117120 a(1)=1. a(n) is smallest positive integer not occurring earlier in the sequence where a(n) is congruent to -1 (mod a(n-1)).

Original entry on oeis.org

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

Views

Author

Leroy Quet, Apr 19 2006

Keywords

Comments

Sequence is a permutation of the positive integers.
The permutation is self-inverse. Except for fixed points 1, 2, 3 it consists completely of 2-cycles: (4,5), (6,7), (8,11), (9,10), (12,15), (13,14), (16,23), (17,22), ..., (24,31), ..., (32,47), ... . - Klaus Brockhaus
The permutation transforms enumeration system of positive irreducible fractions A071766/A229742 (HCS) into enumeration system A245325/A245326, and vice versa. - Yosu Yurramendi, Jun 09 2015
A092569(a(n)) = a(A092569(n)), n > 0.
A258746(a(n)) = a(A258746(n)), n > 0.
A258996(a(n)) = a(A258996(n)), n > 0.
A054429(a(n)) = a(A054429(n)), n > 0.
a(n) = A054429(A063946(n)) = A063946(A054429(n)), n > 0. - Yosu Yurramendi, Mar 23 2017

Crossrefs

Programs

  • Maple
    A[1]:= 1: A[2]:= 2: B[1]:= 0: B[2]:= 0:
    for n from 3 to 100 do
      for m from A[n-1]-1 by A[n-1] while assigned(B[m]) do od:
      A[n]:= m;
      B[m]:= 0;
    od:
    seq(A[n],n=1..100); # Robert Israel, Jun 09 2015
  • Mathematica
    f[n_] := Block[{a = {1}, i, k}, Do[k = 1; While[Or[Mod[k, a[[i - 1]]] != a[[i - 1]] - 1, MemberQ[a, k]], k++]; AppendTo[a, k], {i, 2, n}]; a]; f@ 120 (* Michael De Vlieger, Jun 11 2015 *)
    A[n_]:= If[n<4, n, If[EvenQ[n], 2A[n/2] + 1, 2A[(n - 1)/2]]]; Table[A[n], {n, 100}] (* Indranil Ghosh, Mar 21 2017 *)
    f[lst_List] := Block[{k = 2, m = lst[[-1]]}, While[ MemberQ[lst, k] || 1 + Mod[k, m] != m, k++]; Append[lst, k]]; Nest[f, {1}, 70] (* Robert G. Wilson v, Jan 22 2018 *)
  • PARI
    A(n) = if(n<4, n, if(n%2, 2*A(n\2), 2*A(n/2)+1));
    for(n=1, 50, print1(A(n), ", ")) \\ Indranil Ghosh, Mar 21 2017
  • R
    a <- 1:3 # If it were c(1, 3, 2), it would be A054429
    maxn <- 50 # by choice
    #
    for(n in 2:maxn){
      a[2*n  ] <- 2*a[n]+1
      a[2*n+1] <- 2*a[n]
    }
    #
    a
    # Yosu Yurramendi, Jun 08 2015
    

Formula

For n >= 2: If a(n-1) = 2^m, m=positive integer, then a(n)= 2^(m+1)-1. If a(n-1) = 3*2^m, m= nonnegative integer, then a(n) = 3*2^(m+1)-1. Otherwise, a(n) = a(n-1) -1.
For n >= 2: a(2*n) = 2*a(n)+1, a(2*n+1) = 2*a(n). - Yosu Yurramendi, Jun 08 2015

Extensions

More terms from Klaus Brockhaus

A284459 Permutation of the positive integers: this permutation transforms the enumeration system of positive irreducible fractions A002487/A002487' (Calkin-Wilf) into the enumeration system A245327/A245328, and A162911/A162912 (Drib) into A020651/A020650 (Yu-Ting inverted).

Original entry on oeis.org

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

Views

Author

Yosu Yurramendi, Mar 27 2017

Keywords

Comments

The inverse permutation is A284460.

Crossrefs

Programs

  • R
    maxrow <- 12 # by choice
    a <- 1
    b01 <- 1
    for(m in 0:maxrow){
      b01 <- c(b01, c(1-b01[2^m:(2^(m+1)-1)], b01[2^m:(2^(m+1)-1)]) )
      for(k in 0:(2^m-1)){
        a[2^(m+1) +       k] <- a[2^m + k] + 2^(m + b01[2^(m+1) +       k])
        a[2^(m+1) + 2^m + k] <- a[2^m + k] + 2^(m + b01[2^(m+1) + 2^m + k])
    }}
    a
    # Yosu Yurramendi, Mar 27 2017
    
  • R
    maxblock <- 7 # by choice
    a <- 1:3
    for(n in 4:2^maxblock){
    ones <- which(as.integer(intToBits(n)) == 1)
    nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
    anbit <- nbit
    for(i in 2:(length(anbit) - 1))
       anbit[i] <- 1 - bitwXor(anbit[i], anbit[i-1])
    a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
    }
    a
    # Yosu Yurramendi, Apr 25 2021

Formula

a(n) = A258996(A231551(n)) = A231551(A092569(n)), n > 0 . - Yosu Yurramendi, Apr 10 2017

A231551 Position of n in A231550.

Original entry on oeis.org

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

Views

Author

Alex Ratushnyak, Nov 10 2013

Keywords

Comments

This permutation transforms the enumeration system of positive irreducible fractions A002487/A002487' (Calkin-Wilf) into the enumeration system A020651/A020650, and A162911/A162912 (Drib) the enumeration system into A245327/A245326. - Yosu Yurramendi, Jun 16 2015

Crossrefs

Programs

  • Mathematica
    Join[{0, 1}, Table[d = Reverse@IntegerDigits[n, 2]; FromDigits[Reverse@Append[FoldList[BitXor, d[[1]], Most@Rest@d], d[[-1]]], 2], {n, 2, 67}]] (* Ivan Neretin, Dec 28 2016 *)
  • Python
    for n in range(99):
      bits = [0]*64
      orig = [0]*64
      l = int.bit_length(int(n))
      t = n
      for i in range(l):
        bits[i] = orig[i] = t&1
        t>>=1
      #for i in range(1, l-1):  bits[i] ^= orig[i-1]   # A231550
      for i in range(1, l-1):  bits[i] ^= bits[i-1]   # A231551
      #for i in range(l-1):  bits[i] ^= orig[i+1]      # A003188
      #for i in range(1, l):  bits[l-1-i] ^= bits[l-i]  # A006068
      t = 0
      for i in range(l):  t += bits[i]<
    				
  • R
    maxrow <- 8 # by choice
    b01 <- 0 # b01 is going to be A010059
    a <- 1
    for(m in 0:maxrow) for(k in 0:(2^m-1)){
       b01[2^(m+1)+    k] <-     b01[2^m+k]
         a[2^(m+1)+    k] <-       a[2^m+k]  + 2^(m+b01[2^(m+1)+    k])
       b01[2^(m+1)+2^m+k] <- 1 - b01[2^m+k]
         a[2^(m+1)+2^m+k] <-       a[2^m+k]  + 2^(m+b01[2^(m+1)+2^m+k])
    }
    (a <- c(0,a))
    # Yosu Yurramendi, Apr 10 2017
    
  • R
    maxblock <- 8 # by choice
    a <- 1:3
    for(n in 4:2^maxblock){
    ones <- which(as.integer(intToBits(n)) == 1)
    nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
    anbit <- nbit
    for(i in 2:(length(anbit) - 1))
       anbit[i] <- bitwXor(anbit[i], anbit[i-1])  # ?bitwXor
    a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
    }
    (a <- c(0,a))
    # Yosu Yurramendi, Apr 25 2021

Formula

A231550(a(n)) = a(A231550(n)) = n.
a(n) = A258996(A284460(n)) = A284459(A092569(n)), n > 0. - Yosu Yurramendi, Apr 10 2017
a(n) = A054429(A153154(n)), n > 0. - Yosu Yurramendi, Oct 04 2021

A231550 Permutation of nonnegative integers: for each bit[i] in the binary representation, except the most and the least significant bits, set bit[i] = bit[i] XOR bit[i-1], where bit[i-1] is the less significant bit, XOR is the binary logical exclusive or operator.

Original entry on oeis.org

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

Author

Alex Ratushnyak, Nov 10 2013

Keywords

Comments

This permutation transforms the enumeration system of positive irreducible fractions A020651/A020650 into the enumeration system A002487/A002487' (Calkin-Wilf), and enumeration system A245327/A245326 into A162911/A162912 (Drib). - Yosu Yurramendi, Jun 16 2015

Crossrefs

Programs

  • Mathematica
    Join[{0, 1}, Table[d = IntegerDigits[n, 2]; FromDigits[Join[{d[[1]]}, BitXor[Most@Rest@d, Rest@Rest@d], {d[[-1]]}], 2], {n, 2, 68}]] (* Ivan Neretin, Dec 28 2016 *)
  • PARI
    a(n) = bitxor(n, if(n>3, bitand(n<<1, bitneg(0,logint(n,2))))); \\ Kevin Ryde, Jul 17 2021
  • Python
    for n in range(99):
      bits = [0]*64
      orig = [0]*64
      l = int.bit_length(int(n))
      t = n
      for i in range(l):
        bits[i] = orig[i] = t&1
        t>>=1
      for i in range(1, l-1):  bits[i] ^= orig[i-1]   # A231550
      #for i in range(1, l-1):  bits[i] ^= bits[i-1]   # A231551
      #for i in range(l-1):  bits[i] ^= orig[i+1]      # A003188
      #for i in range(1,l):  bits[l-1-i] ^= bits[l-i]  # A006068
      t = 0
      for i in range(l):  t += bits[i]<
    				
  • R
    a <- 1
    maxlevel <- 8 # by choice
    #
    for(m in 0:maxlevel) for(k in 0:(2^m-1)){
      a[2^(m+1)  +2*k] <- 2*a[2^m+k]
      a[2^(m+2)-1-2*k] <- 2*a[2^m+k] + 1
    }
    (a <- c(0,a))
    # Yosu Yurramendi, Apr 10 2017
    

Formula

a(A231551(n)) = A231551(a(n)) = n.
a(n) = A284460(A258996(n)) = A092569(A284460(n)), n > 0. - Yosu Yurramendi, Apr 10 2017
Showing 1-10 of 11 results. Next