

A030298


List of permutations of 1,2,3,...,n for n=1,2,3,..., in lexicographic order.


40



1, 1, 2, 2, 1, 1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1, 1, 2, 3, 4, 1, 2, 4, 3, 1, 3, 2, 4, 1, 3, 4, 2, 1, 4, 2, 3, 1, 4, 3, 2, 2, 1, 3, 4, 2, 1, 4, 3, 2, 3, 1, 4, 2, 3, 4, 1, 2, 4, 1, 3, 2, 4, 3, 1, 3, 1, 2, 4, 3, 1, 4, 2, 3, 2, 1, 4, 3, 2, 4, 1, 3, 4, 1, 2, 3, 4, 2, 1, 4, 1, 2, 3, 4, 1, 3, 2, 4, 2
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,3


COMMENTS

Contains every finite sequence of distinct numbers...infinitely many times.


LINKS

Reinhard Zumkeller, Rows n=1..7 of triangle, flattened
Daniel Forgues, Tilman Piesk, et al, Orderings, OEIS Wiki.
A. Karttunen, Ranking and unranking functions, OEIS Wiki.
Index entries for sequences related to permutations


FORMULA

Start with 1, then 12 and 21, then the 6 permutations of 123 in lexical order: 123, 132, 213, 231, 312, 321 and so on.


EXAMPLE

The permutations can be written as
1,
12, 21,
123, 132, 213, 231, 312, 321, etc.
Write them in order and insert commas.


MATHEMATICA

f[n_] := Permutations[Range@ n, {n}]; Array[f, 4] // Flatten (* Robert G. Wilson v, Dec 18 2012 *)


PROG

(Haskell)
import Data.List (permutations, sort)
a030298 n k = a030298_tabf !! (n1) (k1)
a030298_row = concat . sort . permutations . enumFromTo 1
a030298_tabf = map a030298_row [1..]
 Reinhard Zumkeller, Mar 29 2012
(MIT/GNU Scheme, with Antti Karttunen's intseqlibrary):
;; Note that in Scheme, vector indexing is zerobased.
;; Requires also A055089permvec from A055089.
(define (A030298 n) (vectorref (A030298permvec (A084556 (A084557 n)) (A220660 (A084557 n))) (A220663 n)))
(define (A030298permvec size rank) (vectorreverse (vector1invert (A055089permvec size rank))))
(define (vector1invert vec) (makeinitializedvector (vectorlength vec) (lambda (i) (1+ ( (vectorlength vec) (vectorref vec i))))))
(define (vectorreverse vec) (makeinitializedvector (vectorlength vec) (lambda (i) (vectorref vec ( (vectorlength vec) i 1)))))


CROSSREFS

A030299 gives the initial portion of these same permutations as decimally encoded numbers.
Cf. A098280, A098281, A030299, A170942.
Cf. A001563 (row lengths), A001286 (row sums).
Cf. A030496 for another ordering.
The same information is essentially given in A055089, but in more compact way, by skipping those permutations which start with a fixed element (cf. A220696).
A220660(n) tells the zerobased rank r of the nth permutation in this sequence, among all finite permutations of the same size.
A220663(n) tells the zerobased position (from the left) of that a(n) in that permutation of rank r.
A084557(n) tells that the nth term a(n) belongs to the a(n):th lexicographically ordered permutation from the start (its "global rank").
A220660(A084557(n)) tells the "local rank" of the permutation (amongst the permutations of the same size) to which the nth term a(n) belongs.
(A130664(n),A084555(n)) = (1,1),(2,3),(4,5),(6,8),(9,11),(12,14),... gives the starting and ending offsets of the nth permutation in this list.
Sequence in context: A016533 A122915 A182592 * A098281 A207324 A103343
Adjacent sequences: A030295 A030296 A030297 * A030299 A030300 A030301


KEYWORD

nonn,tabf


AUTHOR

Clark Kimberling


EXTENSIONS

Entry revised Feb 02 2006 by N. J. A. Sloane.
Keyword tabf added by Reinhard Zumkeller, Mar 29 2012


STATUS

approved



