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.
%I A306428 #15 May 29 2024 13:48:19 %S A306428 1,21,312,132,231,321,4123,1423,2413,4213,1243,2143,3412,4312,1342, %T A306428 3142,4132,1432,2341,3241,4231,2431,3421,4321,51234,15234,25134,52134, %U A306428 12534,21534,35124,53124,13524,31524,51324,15324,23514,32514,52314,25314,35214,53214,12354,21354,31254 %N A306428 Decimal representation of permutations of lengths 1, 2, 3, ... %C A306428 One way to generate the permutations is by using the factorial base (not to be confused with the Lehmer code). %C A306428 Here is a detailed example showing how to compute a(2982). %C A306428 We have i = 2982 = (4, 0, 4, 1, 0, 0, 0) in the factorial base. %C A306428 So the initial vector "0" is (1, 2, 3, 4, 5, 6, 7), using seven active digits. %C A306428 The factorial base vector is reversed, giving (0, 0, 0, 1, 4, 0, 4). %C A306428 The instructions are to read from the factorial base vector, producing rotations to the right by as many steps as the column says, in the following order: %C A306428 Start on the right; on the vector "0", a rotation of 4 units is made %C A306428 (0, 0, 0, 1, 4, 0, [4]) %C A306428 (1, 2, 3, 4, 5, 6, 7) %C A306428 The result is: %C A306428 (4, 5, 6, 7, 1, 2, 3) %C A306428 The 3 is retained, one column is advanced. %C A306428 Next a rotation of 0 units is made (the null rotation) %C A306428 (0, 0, 0, 1, 4, [0], 4) %C A306428 (4, 5, 6, 7, 1, 2, 3) %C A306428 The result is: %C A306428 (4, 5, 6, 7, 1, 2, 3) %C A306428 The 2 is retained, one column is advanced. %C A306428 Now a rotation of 4 units is made %C A306428 (0, 0, 0, 1, [4], 0, 4) %C A306428 (4, 5, 6, 7, 1, 2, 3) %C A306428 The result is: %C A306428 (5, 6, 7, 1, 4, 2, 3) %C A306428 The 4 is retained, one column is advanced. %C A306428 Now a rotation of 1 units is made %C A306428 (0, 0, 0, [1], 4, 0, 4) %C A306428 (5, 6, 7, 1, 4, 2, 3) %C A306428 The result is: %C A306428 (1, 5, 6, 7, 4, 2, 3) %C A306428 The 7 is retained, one column is advanced. %C A306428 Now 3 null rotations are made. %C A306428 All remaining values are retained: 6, 5, and 1 %C A306428 Thus 2982 represents the permutation: (1, 5, 6, 7, 4, 2, 3) %C A306428 Or a(2982) = 1567423. %e A306428 The sequence may be regarded as a triangle, where each row consists of permutations of N terms; i.e., we have %e A306428 1/,2,1/,3,1,2;1,3,2;2,3,1;3,2,1/4,1,2,3;1,4,2,3;2,4,1,3;... %e A306428 Append to each an infinite number of fixed terms and we get a list of rearrangements of the natural numbers, but with only a finite number of terms permuted: %e A306428 1/2,3,4,5,6,7,8,9,... %e A306428 2,1/3,4,5,6,7,8,9,... %e A306428 3,1,2/4,5,6,7,8,9,... %e A306428 1,3,2/4,5,6,7,8,9,... %e A306428 2,3,1/4,5,6,7,8,9,... %e A306428 3,2,1/4,5,6,7,8,9,... %e A306428 4,1,2,3/5,6,7,8,9,... %e A306428 1,4,2,3/5,6,7,8,9,... %e A306428 2,4,1,3/5,6,7,8,9,... %e A306428 Alternatively, if we take only the first n terms of each such infinite row, then the first n! rows give all permutations of the elements 0,1,2,...,n-1. %o A306428 (Visual Basic) %o A306428 ' The following program is developed in Visual Basic, and works for N = 0 to N = 9. %o A306428 ' This restriction is imposed by the number of lines in Excel spreadsheets. %o A306428 ' In this example, N = 5. %o A306428 ' To modify N, you should only change the definition of Dim A(5) to Dim A(N), and %o A306428 change the value in N = 5. %o A306428 Option Explicit %o A306428 Dim Fila As Double, N As Double %o A306428 Dim A(5) As Double %o A306428 Sub Factorial() %o A306428 Dim J As Double, M As Double, O As Double, Y As Double, I As Double %o A306428 Dim Z As Double, R As Double, V As Double, Aux As Double %o A306428 Fila = 0 %o A306428 M = 1 %o A306428 N = 5 %o A306428 For J = 1 To N %o A306428 A(J) = J %o A306428 M = M * A(J) %o A306428 Next J %o A306428 For Fila = 0 To M - 1 %o A306428 V = M %o A306428 Z = N %o A306428 Do While Z > 1 %o A306428 V = V / Z %o A306428 If Fila Mod V = 0 Then %o A306428 R = Z %o A306428 Z = 1 %o A306428 Else %o A306428 Z = Z - 1 %o A306428 End If %o A306428 Loop %o A306428 Y = R \ 2 %o A306428 If Y > 0 Then %o A306428 For Z = 1 To Y %o A306428 Aux = A(Z) %o A306428 A(Z) = A(R - Z + 1) %o A306428 A(R - Z + 1) = Aux %o A306428 Next Z %o A306428 Call PrintData %o A306428 End If %o A306428 Next Fila %o A306428 End Sub %o A306428 Sub PrintData() %o A306428 Dim I As Integer %o A306428 For I = 1 To N %o A306428 Range("A1:G5040").Cells(Fila + 1, I) = N + 1 - A(I) %o A306428 Next I %o A306428 End Sub %K A306428 nonn %O A306428 0,2 %A A306428 _Raúl Mario Torres Silva_, Feb 14 2019