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.

A256210 Lexicographically earliest permutation of positive integers starting with 2 such that a(a(n)+a(n+1)) is odd for all n.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Mar 26 2015

Keywords

Comments

This is the sequence U defined in the comments on A255003.

Crossrefs

Cf. A255003.
Cf. A256371 (inverse), A256372 (fixed points).

Programs

  • Haskell
    after Robert Israel's Maple program
    import Data.IntSet (empty, member, insert)
    a256210 n = a256210_list !! (n-1)
    a256210_list = 2 : f [2 ..] 2 [1, 3 ..] [4, 6 ..] empty where
       f (x:xs) y us'@(u:us) vs'@(v:vs) s
         | member x s || u < v = u : f xs u us vs' (insert (y + u) s)
         | otherwise           = v : f xs v us' vs (insert (y + v) s)
    -- Reinhard Zumkeller, Mar 26 2015
  • Maple
    N:= 100: # to get a(n) for n <= N
    maxodd:= -1:
    maxeven:= 2:
    a[1]:= 2:
    needodd:= {}:
    for n from 2 to N do
      if member(n,needodd) or maxodd < maxeven then
         a[n]:= maxodd + 2;
         maxodd:= a[n];
      else
         a[n]:= maxeven + 2;
         maxeven:= a[n];
      fi;
      needodd:= needodd union {a[n-1]+a[n]};
    od:
    seq(a[n],n=1..N); # Robert Israel, Mar 26 2015
  • Mathematica
    nn = 100;
    maxodd = -1;
    maxeven = 2;
    a[1] = 2;
    needodd = {};
    For[n = 2, n <= nn, n++,
        If[MemberQ[needodd, n] || maxodd < maxeven,
           a[n] = maxodd + 2;
           maxodd = a[n]
       ,
           a[n] = maxeven + 2;
           maxeven = a[n]
       ];
        needodd = needodd ~Union~ {a[n-1]+a[n]};
    ];
    Array[a, nn] (* Jean-François Alcover, Aug 04 2018, after Robert Israel *)