Mathieu Carbou on Sun, 07 Oct 2012 01:56:23 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

numtoperm abd Factorial Number System


Hello,

I just have the following code:

n=3
i=5
{
    for(x=0,i,
        p=numtoperm(n, x);
        print1(p " ");
        for(i=1,n,print1(n-p[i]));
        print("")
    )
}
\q

which prints:

[3, 2, 1] 012
[3, 1, 2] 021
[2, 3, 1] 102
[1, 3, 2] 201
[2, 1, 3] 120
[1, 2, 3] 210

I was much more expecting something like:

[3, 2, 1] 012
[3, 1, 2] 021
[2, 3, 1] 102
[2, 1, 3] 120
[1, 3, 2] 201
[1, 2, 3] 210

which matches a lexicographic orgering and the factorial number system.

I was wondering why in PARI the numtoperm does not match the Nth permutation in the factorial number system ?

Is there a way to use numtoperm to get the good result or I have to code a function which decompose the number in the factorial number system by myself ?

--
Mathieu Carbou
Cell: 514-660-4287