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

A273494 a(n) = A245325(n) + A245326(n).

Original entry on oeis.org

2, 3, 3, 5, 4, 5, 4, 8, 7, 7, 5, 8, 7, 7, 5, 13, 11, 12, 9, 11, 10, 9, 6, 13, 11, 12, 9, 11, 10, 9, 6, 21, 18, 19, 14, 19, 17, 16, 11, 18, 15, 17, 13, 14, 13, 11, 7, 21, 18, 19, 14, 19, 17, 16, 11, 18, 15, 17, 13, 14, 13, 11, 7, 34, 29, 31, 23, 30, 27, 25, 17, 31, 26, 29, 22, 25, 23, 20, 13, 29, 25, 26, 19, 27, 24, 23, 16, 23
Offset: 1

Views

Author

Yosu Yurramendi, May 23 2016

Keywords

Comments

The terms (n>0) may be written as a left-justified array with rows of length 2^m, m >= 0:
2,
3, 3,
5, 4, 5, 4,
8, 7, 7, 5, 8, 7, 7, 5,
13,11,12, 9,11,10, 9, 6,13,11,12, 9,11,10, 9, 6,
21,18,19,14,19,17,16,11,18,15,17,13,14,13,11, 7,21,18,19,14,19,17,...
All columns have the Fibonacci sequence property: a(2^(m+2) + k) = a(2^(m+1) + k) + a(2^m + k), m >= 0, 0 <= k < 2^m (empirical observations).
The terms (n>0) may also be written as a right-justified array with rows of length 2^m, m >= 0:
2,
3, 3,
5, 4, 5, 4,
8, 7, 7, 5, 8, 7, 7, 5,
13,11,12, 9,11,10, 9, 6,13,11,12, 9,11,10, 9, 6,
..., 18,15,17,13,14,13,11, 7,21,18,19,14,19,17,16,11,18,15,17,13,14,13,11, 7,
Each column is an arithmetic sequence. The differences of the arithmetic sequences give the sequence A071585: a(2^(m+1)-1-k) - a(2^m-1-k) = A071585(k), m >= 0, 0 <= k < 2^m.
n > 1 occurs in this sequence phi(n) = A000010(n) times, as it occurs in A007306 (Franklin T. Adams-Watters's comment), which is the sequence obtained by adding numerator and denominator in the Calkin-Wilf enumeration system of positive rationals. A245325(n)/A245326(n) is also an enumeration system of all positive rationals, and in each level m >= 0 (ranks between 2^m and 2^(m+1)-1) rationals are the same in both systems. Thus a(n) has the same terms in each level as A007306.
The same property occurs in all numerator+denominator sequences of enumeration systems of positive rationals, as, for example, A007306 (A007305+A047679), A071585 (A229742+A071766), A086592 (A020650+A020651), A268087 (A162909+A162910).

Crossrefs

Programs

  • PARI
    a(n) = my(x=1, y=1); for(i=0, logint(n, 2), if(bittest(n, i), [x, y]=[x+y, y], [x, y]=[y, x+y])); x \\ Mikhail Kurkov, Mar 10 2023

Formula

a(n) = A273493(A059893(n)), a(A059893(n)) = A273493(n), n > 0. - Yosu Yurramendi, May 30 2017
a(n) = A007306(A059893(A180200(n))) = A007306(A059894(A154435(n))). - Yosu Yurramendi, Sep 20 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

A083329 a(0) = 1; for n > 0, a(n) = 3*2^(n-1) - 1.

Original entry on oeis.org

1, 2, 5, 11, 23, 47, 95, 191, 383, 767, 1535, 3071, 6143, 12287, 24575, 49151, 98303, 196607, 393215, 786431, 1572863, 3145727, 6291455, 12582911, 25165823, 50331647, 100663295, 201326591, 402653183, 805306367, 1610612735, 3221225471, 6442450943
Offset: 0

Views

Author

Paul Barry, Apr 27 2003

Keywords

Comments

Apart from leading term (which should really be 3/2), same as A055010.
Binomial transform of A040001. Inverse binomial transform of A053156.
a(n) = A105728(n+1,2). - Reinhard Zumkeller, Apr 18 2005
Row sums of triangle A133567. - Gary W. Adamson, Sep 16 2007
Row sums of triangle A135226. - Gary W. Adamson, Nov 23 2007
a(n) = number of partitions Pi of [n+1] (in standard increasing form) such that the permutation Flatten[Pi] avoids the patterns 2-1-3 and 3-1-2. Example: a(3)=11 counts all 15 partitions of [4] except 13/24, 13/2/4 which contain a 2-1-3 and 14/23, 14/2/3 which contain a 3-1-2. Here "standard increasing form" means the entries are increasing in each block and the blocks are arranged in increasing order of their first entries. - David Callan, Jul 22 2008
An elephant sequence, see A175654. For the corner squares four A[5] vectors, with decimal values 42, 138, 162, 168, lead to this sequence. For the central square these vectors lead to the companion sequence A003945. - Johannes W. Meijer, Aug 15 2010
The binary representation of a(n) has n+1 digits, where all digits are 1's except digit n-1. For example: a(4) = 23 = 10111 (2). - Omar E. Pol, Dec 02 2012
Row sums of triangle A209561. - Reinhard Zumkeller, Dec 26 2012
If a Stern's sequence based enumeration system of positive irreducible fractions is considered (for example, A007305/A047679, A162909/A162910, A071766/A229742, A245325/A245326, ...), and if it is organized by blocks or levels (n) with 2^n terms (n >= 0), and the fractions, term by term, are summed at each level n, then the resulting sequence of integers is a(n) + 1/2, apart from leading term (which should be 1/2). - Yosu Yurramendi, May 23 2015
For n >= 2, A083329(n) in binary representation is a string [101..1], also 10 followed with (n-1) 1's. For n >= 3, A036563(n) in binary representation is a string [1..101], also (n-2) 1's followed with 01. Thus A083329(n) is a reflection of the binary representation of A036563(n+1). Example: A083329(5) = 101111 in binary, A036563(6) = 111101 in binary. - Ctibor O. Zizka, Nov 06 2018
For n > 0, a(n) is the minimum number of turns in (n+1)-dimensional Euclidean space needed to visit all 2^(n+1) vertices of the (n+1)-cube (e.g., {0,1}^(n+1)) and return to the starting point, moving along straight-line segments between turns (turns may occur elsewhere in R^(n+1)). - Marco Ripà, Aug 14 2025

Examples

			a(0) = (3*2^0 - 2 + 0^0)/2 = 2/2 = 1 (use 0^0=1).
		

Crossrefs

Essentially the same as A055010 and A052940.
Cf. A007505 (primes).
Cf. A266550 (independence number of the n-Mycielski graph).

Programs

  • Haskell
    a083329 n = a083329_list !! n
    a083329_list = 1 : iterate ((+ 1) . (* 2)) 2
    -- Reinhard Zumkeller, Dec 26 2012, Feb 22 2012
    
  • Magma
    [1] cat [3*2^(n-1)-1: n in [1..40]]; // Vincenzo Librandi, Jan 01 2016
  • Maple
    seq(ceil((2^i+2^(i+1)-2)/2), i=0..31); # Zerinvary Lajos, Oct 02 2007
  • Mathematica
    a[1] = 2; a[n_] := 2a[n - 1] + 1; Table[ a[n], {n, 31}] (* Robert G. Wilson v, May 04 2004 *)
    Join[{1}, LinearRecurrence[{3, -2}, {2, 5}, 40]] (* Vincenzo Librandi, Jan 01 2016 *)
  • PARI
    a(n)=(3*2^n-2+0^n)/2 \\ Charles R Greathouse IV, Sep 24 2015
    

Formula

a(n) = (3*2^n - 2 + 0^n)/2.
G.f.: (1-x+x^2)/((1-x)*(1-2*x)). [corrected by Martin Griffiths, Dec 01 2009]
E.g.f.: (3*exp(2*x) - 2*exp(x) + exp(0))/2.
a(0) = 1, a(n) = sum of all previous terms + n. - Amarnath Murthy, Jun 20 2004
a(n) = 3*a(n-1) - 2*a(n-2) for n > 2, a(0)=1, a(1)=2, a(2)=5. - Philippe Deléham, Nov 29 2013
From Bob Selcoe, Apr 25 2014: (Start)
a(n) = (...((((((1)+1)*2+1)*2+1)*2+1)*2+1)...), with n+1 1's, n >= 0.
a(n) = 2*a(n-1) + 1, n >= 2.
a(n) = 2^n + 2^(n-1) - 1, n >= 2. (End)
a(n) = A086893(n) + A061547(n+1), n > 0. - Yosu Yurramendi, Jan 16 2017

A063946 Write n in binary and complement second bit (from the left), with a(0)=0 and a(1)=1.

Original entry on oeis.org

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

Views

Author

Henry Bottomley, Sep 03 2001

Keywords

Comments

From Yosu Yurramendi, Mar 21 2017: (Start)
This sequence is a self-inverse permutation of the integers. Except for fixed points 0, 1, it consists completely of 2-cycles: (2^(m+1)+k, 2^(m+1)+2^m+k), m >= 0, 0 <= k < 2^m.
A071766(a(n)) = A229742(n), A229742(a(n)) = A071766(n), n > 0.
A245325(a(n)) = A245326(n), A245326(a(n)) = A245325(n), n > 0.
A065190(a(n)) = a(A065190(n)), n > 0.
A054429(a(n)) = a(A054429(n)) = A117120(n), n > 0.
A258746(a(n)) = a(A258746(n)), n > 0.
A258996(a(n)) = a(A258996(n)), n > 0. (End)
A324337(a(n)) = A324338(n), A324338(a(n)) = A324337(n), n > 0. - Yosu Yurramendi, Nov 04 2019

Examples

			a(11)=15 since 11 is written in binary as 1011, which changes to 1111, i.e., 15; a(12)=8 since 12 is written as 1100 which changes to 1000, i.e., 8.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember;
      if n<2 then n
    elif n<4 then 5-n
    elif `mod`(n,2)=0 then 2*a(n/2)
    else 2*a((n-1)/2) + 1
      fi; end proc;
    seq(a(n), n = 0..80); # G. C. Greubel, Dec 08 2019
  • Mathematica
    bc[n_]:=Module[{idn2=IntegerDigits[n,2]},If[idn2[[2]]==1,idn2[[2]]=0, idn2[[2]]=1];FromDigits[idn2,2]]; Join[{0,1},Array[bc,80,2]] (* Harvey P. Dale, May 31 2012 *)
    a[n_]:= a[n]= If[n<2, n, If[n<4, 5-n, If[EvenQ[n], 2*a[n/2], 2*a[(n-1)/2] +1]]];  Table[a[n], {n,0,80}] (* G. C. Greubel, Dec 08 2019 *)
  • PARI
    a(n)=if(n<2,n>0,3/2*2^floor(log(n)/log(2))-2^floor(log(4/3*n)/log(2))+n) /* Ralf Stephan */
    
  • PARI
    a(n) = if(n<2,n, bitxor(n, 1<<(logint(n,2)-1))); \\ Kevin Ryde, Apr 09 2020
    
  • Python
    import math
    def a(n): return n if n<2 else 3/2*2**int(math.floor(math.log(n)/math.log(2))) - 2**int(math.floor(math.log(4/3*n)/math.log(2))) + n # Indranil Ghosh, Mar 22 2017
    
  • R
    maxrow <- 8 # by choice
    b01 <- 1
    for(m in 0:(maxrow-1)){
      b01 <- c(b01,rep(0,2^(m+1))); b01[2^(m+1):(2^(m+1)+2^m-1)] <- 1
    }
    a <- c(1,3,2)
    for(m in 0:(maxrow-2))
      for(k in 0:(2^m-1)){
        a[2^(m+2) +                 k] <- a[2^(m+1) + 2^m + k] + 2^((m+1) + b01[2^(m+2) +                 k])
        a[2^(m+2) +         + 2^m + k] <- a[2^(m+1) +       k] + 2^((m+1) + b01[2^(m+2) +         + 2^m + k])
        a[2^(m+2) + 2^(m+1) +       k] <- a[2^(m+1) + 2^m + k] + 2^((m+1) + b01[2^(m+2) + 2^(m+1) +       k])
        a[2^(m+2) + 2^(m+1) + 2^m + k] <- a[2^(m+1) +       k] + 2^((m+1) + b01[2^(m+2) + 2^(m+1) + 2^m + k])
    }
    (a <- c(0,a))  # Yosu Yurramendi, Mar 30 2017
    
  • R
    a <- c(1,3,2)
    maxn <- 63 # by choice
    for(n in 2:maxn){ a[2*n  ] <- 2*a[n]
                      a[2*n+1] <- 2*a[n] + 1  }
    (a <- c(0,a))  # Yosu Yurramendi, Nov 12 2019
    
  • Sage
    @CachedFunction
    def a(n):
        if (n<2): return n
        elif (n<4): return 5-n
        elif (mod(n,2)==0): return 2*a(n/2)
        else: return 2*a((n-1)/2) + 1
    [a(n) for n in (0..80)] # G. C. Greubel, Dec 08 2019

Formula

If 2*2^k <= n < 3*2^k then a(n) = n + 2^k; if 3*2^k <= n < 4*2^k then a(n) = n - 2^k.
a(0)=0, a(1)=1, a(2)=3, a(3) = 2, a(2n) = 2*a(n), a(2n+1) = 2*a(n) + 1. - Ralf Stephan, Aug 23 2003

A233279 Permutation of nonnegative integers: a(n) = A054429(A006068(n)).

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Dec 18 2013

Keywords

Comments

This permutation transforms the enumeration system of positive irreducible fractions A007305/A047679 (Stern-Brocot) into the enumeration system A071766/A229742 (HCS), and the enumeration system A162909/A162910 (Bird) into A245325/A245326. - Yosu Yurramendi, Jun 09 2015

Crossrefs

Inverse permutation: A233280.

Programs

  • Mathematica
    Module[{nn = 6, s}, s = Flatten[Table[Range[2^(n + 1) - 1, 2^n, -1], {n, 0, nn}]]; Map[If[# == 0, 0, s[[#]]] &, Table[Fold[BitXor, n, Quotient[n, 2^Range[BitLength[n] - 1]]], {n, 0, 2^nn}]]] (* Michael De Vlieger, Apr 06 2017, after Harvey P. Dale at A054429 and Jan Mangaldan at A006068 *)
  • Python
    from sympy import floor
    def a006068(n):
        s=1
        while True:
            ns=n>>s
            if ns==0: break
            n=n^ns
            s<<=1
        return n
    def a054429(n): return 1 if n==1 else 2*a054429(floor(n/2)) + 1 - n%2
    def a(n): return 0 if n==0 else a054429(a006068(n)) # Indranil Ghosh, Jun 11 2017
  • R
    maxrow <- 8 # by choice
    a <- 1:3
    for(m in 0:maxrow) for(k in 0:(2^m-1)){
    a[2^(m+2)+            k] <- a[2^(m+1)+    k] + 2^(m+1)
    a[2^(m+2)+        2^m+k] <- a[2^(m+1)+2^m+k] + 2^(m+1)
    a[2^(m+2)+2^(m+1)+    k] <- a[2^(m+1)+2^m+k] + 2^(m+2)
    a[2^(m+2)+2^(m+1)+2^m+k] <- a[2^(m+1)+   +k] + 2^(m+2)
    }
    (a <- c(0,a))
    # Yosu Yurramendi, Apr 05 2017
    
  • R
    # Given n, compute a(n) by taking into account the binary representation of n
    maxblock <- 7 # by choice
    a <- 1
    for(n in 2:2^maxblock){
      ones <- which(as.integer(intToBits(n)) == 1)
      nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
      anbit <- nbit
      for(k in 2^(0:floor(log2(length(nbit))))  )
        anbit <- bitwXor(anbit, c(anbit[-(1:k)], rep(0,k))) # ?bitwXor
      anbit[0:(length(anbit) - 1)] <- 1 - anbit[0:(length(anbit)-1)]
      a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
    }
    (a <- c(0,a))
    # Yosu Yurramendi, May 29 2021
    
  • Scheme
    (define (A233279 n) (A054429 (A006068 n)))
    

Formula

a(n) = A054429(A006068(n)).
a(n) = A006068(A063946(n)).
a(n) = A154435(A054429(n)).
a(n) = A180200(A258746(n)) = A117120(A180200(n)), n > 0. - Yosu Yurramendi, Apr 10 2017

A180200 a(0)=0, a(1)=1; for n > 1, a(n) = 2*m + 1 - (n mod 2 + m mod 2) mod 2, where m = a(floor(n/2)).

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Aug 15 2010

Keywords

Comments

Permutation of the natural numbers with inverse A180201;
A180198(n) = a(a(n));
a(A180199(n)) = A180199(a(n)) = A180201(n);
a(A075427(n)) = A075427(n).
This permutation transforms the enumeration system of positive irreducible fractions A007305/A047679 (Stern-Brocot) into the enumeration system A245325/A245326, and enumeration system A162909/A162910 (Bird) into A071766/A229742 (HCS). - Yosu Yurramendi, Jun 09 2015

Crossrefs

Programs

  • C
    #include 
    int a(int n){
        int m;
        if (n<2){return n;}
        else{
            m=a(n/2);
            return 2*m  + 1 - (n%2 + m%2)%2;
        }
    }
    int main()
    {
        int n=0;
        for(; n<=100; n++)
        printf("%d, ", a(n));
        return 0;
    } /* Indranil Ghosh, Apr 05 2017 */
    
  • Maple
    a:= proc(n) option remember; `if`(n<2, n, (m->
          2*m+1-irem(m+n, 2))(a(iquo(n, 2))))
        end:
    seq(a(n), n=0..72);  # Alois P. Heinz, May 29 2021
  • Mathematica
    a[0] = 0; a[1] = 1; a[n_] := a[n] = 2 # + 1 - Mod[Mod[n, 2] + Mod[#, 2], 2] &@ a[Floor[n/2]]; Table[a@ n, {n, 0, 72}] (* Michael De Vlieger, Apr 02 2017 *)
  • PARI
    a(n) = if(n<2, n, my(m=a(n\2)); 2*m + 1 - (n%2 + m%2)%2); \\ Indranil Ghosh, Apr 05 2017
    
  • Python
    def a(n):
        if n<2:return n
        else:
            m=a(n//2)
            return 2*m + 1 - (n%2 + m%2)%2 # Indranil Ghosh, Apr 05 2017
    
  • R
    maxn <- 63 # by choice
    a <- 1
    for(n in 1:maxn){
    a[2*n  ] <- 2*a[n] + (a[n]%%2 == 0)
    a[2*n+1] <- 2*a[n] + (a[n]%%2 != 0)}
    a <- c(0,a)
    # Yosu Yurramendi, May 23 2020

Formula

a(n) = A258746(A233279(n)) = A233279(A117120(n)), n > 0. - Yosu Yurramendi, Apr 10 2017 [Corrected by Yosu Yurramendi, Mar 14 2025]
a(0) = 0, a(1) = 1, for n > 0 a(2*n) = 2*a(n) + [a(n) even], a(2*n + 1) = 2*a(n) + [a(n) odd]. - Yosu Yurramendi, May 23 2020
a(n) = A054429(A154435(n)) = A006068(A054429(n)), n > 0. - Yosu Yurramendi, Jun 05 2021

Extensions

Name edited by Jon E. Schoenfield, Apr 05 2017

A092569 Permutation of integers a(a(n)) = n. In binary representation of n, transformation of inner bits, 1 <-> 0, gives binary representation of a(n).

Original entry on oeis.org

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

Views

Author

Zak Seidov, Feb 28 2004

Keywords

Comments

Primes which stay primes under transformation "opposite inner bits", A092570.
This permutation transforms the enumeration system of positive irreducible fractions A020651/A020650 into the enumeration system A245327/A245326, and vice versa. - Yosu Yurramendi, Jun 16 2015
A117120(a(n)) = a(A117120(n)), n > 0.
A258996(a(n)) = a(A258996(n)), n > 0.
A258746(a(n)) = a(A258746(n)), n > 0.
A054429(a(n)) = a(A054429(n)), n > 0.
a(n) = A054429(A065190(n)) = A065190(A054429(n)), n > 0. - Yosu Yurramendi, Mar 23 2017

Examples

			a(9)=15 because 9_10 = 1001_2, transformation of inner bits gives 1001_2 -> 1111_2 = 15_10.
		

Crossrefs

Cf. A092570.

Programs

  • Mathematica
    bb={0, 1, 2, 3};Do[id=IntegerDigits[n, 2];Do[id[[i]]=1-id[[i]], {i, 2, Length[id]-1}];bb=Append[bb, FromDigits[id, 2]], {n, 4, 1000}];fla=Flatten[bb]
    (* Second program: *)
    Table[If[n < 2, n, Function[b, FromDigits[#, 2] &@ Join[{First@ b}, Most[Rest@ b] /. { 0 -> 1, 1 -> 0}, {Last@ b}]]@ IntegerDigits[n, 2]], {n, 0, 70}] (* Michael De Vlieger, Apr 03 2017 *)
  • PARI
    T(n)={pow2=2;v=binary(n);L=#v-1;forstep(k=L,2,-1,if(v[k],n-=pow2,n+=pow2);pow2*=2);return(n)};
    for(n=0,70,print1(T(n),", ")) \\ Washington Bomfim, Jan 18 2011
    
  • R
    maxrow <- 8 # by choice
    a <- 1:3 # If it were c(1, 3, 2), it would be A054429
    for(m in 1:maxrow) for(k in 0:(2^m-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
    }
    a
    # Yosu Yurramendi, Apr 10 2017

Formula

a(0) = 0, a(1) = 1, a(2) = 2, a(3) = 3, 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 >= 1, 0 <= k < 2^m. - Yosu Yurramendi, Apr 02 2017

A245325 Numerators of an enumeration system of the reduced nonnegative rational numbers.

Original entry on oeis.org

1, 1, 2, 2, 1, 3, 3, 3, 3, 2, 1, 5, 4, 5, 4, 5, 4, 5, 4, 3, 3, 2, 1, 8, 7, 7, 5, 8, 7, 7, 5, 8, 7, 7, 5, 8, 7, 7, 5, 5, 4, 5, 4, 3, 3, 2, 1, 13, 11, 12, 9, 11, 10, 9, 6, 13, 11, 12, 9, 11, 10, 9, 6, 13, 11, 12, 9, 11, 10, 9, 6, 13, 11, 12, 9, 11, 10, 9, 6, 8, 7, 7, 5, 8, 7, 7, 5, 5, 4, 5, 4, 3, 3, 2, 1, 21, 18, 19, 14, 19
Offset: 1

Views

Author

Yosu Yurramendi, Jul 18 2014

Keywords

Comments

a(n)/A245326(n) enumerates all the reduced nonnegative rational numbers exactly once.
If the terms (n>0) are written as an array (in a left-aligned fashion) with rows of length 2^m, m = 0,1,2,3,...
1,
1,2,
2,1,3,3,
3,3,2,1,5,4,5,4,
5,4,5,4,3,3,2,1,8,7,7,5,8,7,7,5,
8,7,7,5,8,7,7,5,5,4,5,4,3,3,2,1,13,11,12,9,11,10,9,6,13,11,12,9,11,10,9,6,
then the sum of the m-th row is 3^m (m = 0,1,2,), and each column k is a Fibonacci sequence.
If the rows are written in a right-aligned fashion:
1,
1,2,
2, 1,3,3,
3, 3, 2,1, 5, 4,5,4,
5, 4, 5,4, 3, 3,2,1, 8, 7, 7,5, 8, 7,7,5,
8,7,7,5,8,7,7,5,5,4,5,4,3,3,2,1,13,11,12,9,11,10,9,6,13,11,12,9,11,10,9,6,
then each column is an arithmetic sequence. The differences of the arithmetic sequences give the sequence A071585 (a(2^(m+1)-1-k) - a(2^m-1-k) = A071585(k), m = 0,1,2,..., k = 0,1,2,...,2^m-1).
If the sequence is considered by blocks of length 2^m, m = 0,1,2,..., the blocks of this sequence are permutations of terms of blocks from A002487 (Stern's diatomic series or the Stern-Brocot sequence), and, more precisely, the reverses of blocks of A229742 (a(2^m+k) = A229742(2^(m+1)-1-k), m = 0,1,2,..., k = 0,1,2,...,2^m-1). Moreover, each block is the bit-reversed permutation of the corresponding block of A245327.

Crossrefs

Programs

  • R
    blocklevel <- 6 # arbitrary
    a <- 1
    for(m in 0:blocklevel) for(k in 0:(2^(m-1)-1)){
      a[2^(m+1)+k]             <- a[2^m+2^(m-1)+k]
      a[2^(m+1)+2^(m-1)+k]     <- a[2^m+k]
      a[2^(m+1)+2^m+k]         <- a[2^(m+1)+k] +  a[2^m+k]
      a[2^(m+1)+2^m+2^(m-1)+k] <- a[2^(m+1)+2^m+k]
    }
    a

Formula

a(n) = A002487(A059893(A180200(n))) = A002487(1+A059893(A154435(n))). - Yosu Yurramendi, Sep 20 2021

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

A233280 Permutation of nonnegative integers: a(n) = A003188(A054429(n)).

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Dec 18 2013

Keywords

Comments

This permutation transforms the enumeration system of positive irreducible fractions A071766/A229742 (HCS) into the enumeration system A007305/A047679 (Stern-Brocot), and the enumeration system A245325/A245326 into A162909/A162910 (Bird). - Yosu Yurramendi, Jun 09 2015

Crossrefs

Inverse permutation: A233279.
Similarly constructed permutation pairs: A003188/A006068, A135141/A227413, A232751/A232752, A233275/A233276, A233277/A233278, A193231 (self-inverse).

Programs

  • Python
    from sympy import floor
    def a003188(n): return n^(n>>1)
    def a054429(n): return 1 if n==1 else 2*a054429(floor(n/2)) + 1 - n%2
    def a(n): return 0 if n==0 else a003188(a054429(n)) # Indranil Ghosh, Jun 11 2017
  • R
    maxrow <- 8 # by choice
    a <- 1
    for(m in 0: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+1)-1-k] + 2^(m+1)
    }
    a
    # Yosu Yurramendi, Apr 05 2017
    
  • Scheme
    (define (A233280 n) (A003188 (A054429 n)))
    ;; Alternative version, based on entangling even & odd numbers with odious and evil numbers:
    (definec (A233280 n) (cond ((< n 2) n) ((even? n) (A000069 (+ 1 (A233280 (/ n 2))))) (else (A001969 (+ 1 (A233280 (/ (- n 1) 2)))))))
    

Formula

a(n) = A003188(A054429(n)).
a(n) = A063946(A003188(n)).
a(n) = A054429(A154436(n)).
a(0)=0, a(1)=1, and otherwise, a(2n) = A000069(1+a(n)), a(2n+1) = A001969(1+a(n)). [A recurrence based on entangling even & odd numbers with odious and evil numbers]
a(n) = A258746(A180201(n)) = A180201(A117120(n)), n > 0. - Yosu Yurramendi, Apr 10 2017
Showing 1-10 of 15 results. Next