View Single Post
 08-16-2013, 05:31 PM PM User | #2 007julien Regular Coder   Join Date: May 2012 Location: France Posts: 174 Thanks: 0 Thanked 27 Times in 25 Posts This page gives all permutations off n numbers. Its uses only the first function getPrm (the second is getNmb) to get the permutation with is factorial number (or this number with the permutation). See wikipedia Factorial_number_system for further explanations. Code: ```

Permutations

``` To find the 15 th permutation of 1234 (from 0 to 23) 1/ - divide 15 by 3!=6 witch is 2 => to take the number of rank 2 of '1234' witch is '3' 2/ - divide the rest by 2!=2 witch is 1 => to take the number of rank 1 of '124' witch is '2' =>'32' 3/ - divide the rest by 1!=1 witch is 1 => to take take the number of rank 1 of '14' witch is '4' =>'324' 4/ - divide the rest by 0!=1 witch is 0 => to take take the number of rank 0 of '1' witch is '1' =>'3241' With this functions there is no need to calculate all permutation to find one (or inversely)... Last edited by 007julien; 08-16-2013 at 07:47 PM..