1. If we have 9 colors of buttons and want to find all its permutations, we know that is P(9,9)=9!=362880. So, we can't remember all of them or find it quick. That's fine. But, how we find Nth in these 362880 permutations without record it first?
2. Same as 1, but if we want to find Nth from a permutation of M, K (M>=K and 1<= N <= P(M,K) ).
3. Same as 2. How about combination?
Logically, all permutations are independent. Therefore, Nth of the permutation can be anything or a given order.
It is no matter M equal to K or not. And, same as combination.
Mathmatically, a simple rule can be used. Let's say, there are B(lue), C(yan), G(reen), O(range), P(urple), R(ed),
V(iolet), W(hite), Y(ellow) buttons in alphabetic order.
a. Set O as N minus 1
b. Set Q as 9
c. Divide O by Q
d. Set R as the remainder plus 1.
e. Pick the Rth button.
f. Set Q to Q minus 1
g. Loop to c till Q >= 1.
For example, the 283401st permutation is:
283401 / 9 = 31489 ... 0 (Pick Blue).
31489 / 8 = 3936 ... 1 (Pick Green)
3936 / 7 = 562 ... 2 (Pick Purple)
562 / 6 = 93 ... 4 (Pick White)
93 / 5 = 18 ... 3 (Pick Violet)
18 / 4 = 4 ... 2 (Pick Red)
4 / 3 = 1 ... 1 (Pick Orange)
1 / 2 = 0 ... 1 (Pick Yellow)
0 / 1 = 0 ... 0 (Pick Cyan)
2. For Nth in P(M,K),
P(M,K) = M!/(M-K)!
So, multiply N by (M-K)!, and then get the "new" N and follow above logic.
Question
Guest
1. If we have 9 colors of buttons and want to find all its permutations, we know that is P(9,9)=9!=362880. So, we can't remember all of them or find it quick. That's fine. But, how we find Nth in these 362880 permutations without record it first?
2. Same as 1, but if we want to find Nth from a permutation of M, K (M>=K and 1<= N <= P(M,K) ).
3. Same as 2. How about combination?
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.