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.

A030299 Decimal representation of permutations of lengths 1, 2, 3, ... arranged lexicographically.

This page as a plain text file.
%I A030299 #65 Jun 28 2025 18:22:56
%S A030299 1,12,21,123,132,213,231,312,321,1234,1243,1324,1342,1423,1432,2134,
%T A030299 2143,2314,2341,2413,2431,3124,3142,3214,3241,3412,3421,4123,4132,
%U A030299 4213,4231,4312,4321,12345,12354,12435,12453,12534,12543,13245,13254,13425
%N A030299 Decimal representation of permutations of lengths 1, 2, 3, ... arranged lexicographically.
%C A030299 This is a list of the permutations in "one-line" notation (cf. Dixon and Mortimer, p. 2). The i-th element of the string is the image of i under the permutation. For example 231 is the permutation that sends 1 to 2, 2 to 3, and 3 to 1. - _N. J. A. Sloane_, Apr 12 2014
%C A030299 Precise definition of the term "Decimal representation" (required for indices n>409113): Numbers N(s) = Sum_{i=1..m} s(i)*10^(m-i), where s runs over the permutations of (1,...,m), and m=1,2,3,.... This also defines the "lexicographical" order: Obviously 21 comes before 123, etc. The lexicographical order of the permutations, for given m, is the same as the natural order of the numbers N(s). - _M. F. Hasler_, Jan 28 2013
%C A030299 An alternate variant, using concatenation of the permutations, is very clumsy once the length exceeds 9. For example, after 987654321 (= A030299(409113), where 409113 = A007489(9)) we would get 12345678910, 12345678109, ... In A030298 this problem has been avoided by listing the elements of permutations as separate terms. [Edited by _M. F. Hasler_, Jan 28 2013]
%C A030299 Sequence A051845 is a base-independent version of this sequence: Permutations of 1...m are considered as numbers written in base m+1. - _M. F. Hasler_, Jan 28 2013
%D A030299 John D. Dixon and Brian Mortimer, Permutation groups. Graduate Texts in Mathematics, 163. Springer-Verlag, New York, 1996. xii+346 pp. ISBN: 0-387-94599-7 MR1409812 (98m:20003).
%H A030299 Antti Karttunen, <a href="/A030299/b030299.txt">Table of n, a(n) for n = 1..5913</a>
%H A030299 OEIS Wiki, <a href="/wiki/Talk:A030299">Discussion about alternate definition(s) of this sequence</a>, started by _M. F. Hasler_, Jan 28 2013
%H A030299 <a href="/index/Per#perm">Index entries for sequences related to permutations</a>
%H A030299 <a href="/index/Se#sequences_which_agree_for_a_long_time">Index entries for sequences which agree for a long time but are different</a>
%p A030299 seq(seq(add(s[i]*10^(m-i),i=1..m),s=combinat:-permute([$1..m])),m=1..5); # _Robert Israel_, Oct 14 2015
%t A030299 Flatten @ Table[FromDigits /@ Permutations[Table[i,{i,n}]],{n,9}] (* For first 409113 terms; _Zak Seidov_, Oct 03 2015 *)
%o A030299 (PARI) is_A030299(n)={ (n>1234567890 & print("maybe")) || vecsort(digits(n))==vector(#Str(n),i,i) } \\ /* use digits(n)=eval(Vec(Str(n))) in older versions lacking this function */ \\ _M. F. Hasler_, Dec 12 2012
%o A030299 (MIT/GNU Scheme)
%o A030299 ;; _Antti Karttunen_, Dec 18 2012
%o A030299 ;; Requires also code from A030298 and A055089:
%o A030299 (define (A030299 n) (vector->base-k (A030298permvec (A084556 n) (A220660 n)) 10))
%o A030299 (define (vector->base-k vec k) (let loop ((i 0) (s 0)) (cond ((= (vector-length vec) i) s) ((>= (vector-ref vec i) k) (error (format #f "Cannot interpret vector ~a in base ~a!" vec k))) (else (loop (+ i 1) (+ (* k s) (vector-ref vec i)))))))
%o A030299 (Python)
%o A030299 from itertools import permutations
%o A030299 def pmap(s, m): return sum(s[i-1]*10**(m-i) for i in range(1, len(s)+1))
%o A030299 def agen():
%o A030299   m = 1
%o A030299   while True:
%o A030299     for s in permutations(range(1, m+1)): yield pmap(s, m)
%o A030299     m += 1
%o A030299 def aupton(terms):
%o A030299   alst, g = [], agen()
%o A030299   while len(alst) < terms: alst += [next(g)]
%o A030299   return alst
%o A030299 print(aupton(42)) # _Michael S. Branicky_, Jan 12 2021
%Y A030299 A007489(n) gives the position (index) of the term corresponding to last permutation of n elements: (n,n-1,...,1).
%Y A030299 The first differences A220664 has interesting fractal structure, see A219664 and A217626.
%Y A030299 Cf. also A030298, A055089, A060117, A181073, A352991 (by concatenation).
%Y A030299 See A240763 for preferential arrangements.
%K A030299 nonn,easy,base
%O A030299 1,2
%A A030299 _N. J. A. Sloane_ and _Clark Kimberling_
%E A030299 Edited by _N. J. A. Sloane_, Feb 23 2010