A030299 Decimal representation of permutations of lengths 1, 2, 3, ... arranged lexicographically.
1, 12, 21, 123, 132, 213, 231, 312, 321, 1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431, 3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321, 12345, 12354, 12435, 12453, 12534, 12543, 13245, 13254, 13425
Offset: 1
References
- 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).
Links
- Antti Karttunen, Table of n, a(n) for n = 1..5913
- OEIS Wiki, Discussion about alternate definition(s) of this sequence, started by _M. F. Hasler_, Jan 28 2013
- Index entries for sequences related to permutations
- Index entries for sequences which agree for a long time but are different
Crossrefs
Programs
-
Maple
seq(seq(add(s[i]*10^(m-i),i=1..m),s=combinat:-permute([$1..m])),m=1..5); # Robert Israel, Oct 14 2015
-
Mathematica
Flatten @ Table[FromDigits /@ Permutations[Table[i,{i,n}]],{n,9}] (* For first 409113 terms; Zak Seidov, Oct 03 2015 *)
-
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 (MIT/GNU Scheme) ;; Antti Karttunen, Dec 18 2012 ;; Requires also code from A030298 and A055089: (define (A030299 n) (vector->base-k (A030298permvec (A084556 n) (A220660 n)) 10)) (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)))))))
-
Python
from itertools import permutations def pmap(s, m): return sum(s[i-1]*10**(m-i) for i in range(1, len(s)+1)) def agen(): m = 1 while True: for s in permutations(range(1, m+1)): yield pmap(s, m) m += 1 def aupton(terms): alst, g = [], agen() while len(alst) < terms: alst += [next(g)] return alst print(aupton(42)) # Michael S. Branicky, Jan 12 2021
Extensions
Edited by N. J. A. Sloane, Feb 23 2010
Comments