[Algorithm] The following is an algorithm for finding a permutation and combination.
From 0 ~ 9, ~ Z: three numbers are randomly selected from the 36 characters to calculate the number of permutation and combination methods.
Please advise
Reply to discussion (solution)
36*36*36 = 46656
36*36*36
I wrote it myself.
/*** Permutation and combination algorithm * C ($ n, $ m) * $ n number of elements * $ m number of elements retrieved from $ n * $ total number of num combinations */function get_combination ($ n, $ m) {if (is_int ($ n) & is_int ($ m) & ($ m <= $ n) {$ a = 1; // initialize for ($ I = 1; $ I <= $ m; $ I ++) {$ a = $ n * $ a; $ B = 1 * $ I; $ n -- ;}$ num = $ a/$ B; return $ num ;}}
Combination formula: c (n, m) = p (n, m)/m! = N! /(N-m )! * M !)
Do you think you are correct?
Combination formula: c (n, m) = p (n, m)/m! = N! /(N-m )! * M !)
Do you think you are correct?
You can try
36*35*34
The sum is 7140.
Half less than you
Combination formula: c (n, m) = p (n, m)/m! = N! /(N-m )! * M !)
Do you think you are correct?
You can try
Echo get_combination (3, 3 );
Output 2
Why not?
Echo get_combination (3, 3 );
Output 2
Why not?
Well, I saw it again.
The formula you wrote is also incorrect.
If you follow your formula
We propose two numbers from two numbers to arrange them equal to 1.
Pair
From the two numbers, we propose that the combination of two numbers is 1.
Arrangement is 2
P (n, m) = n (n-1) (n-2 )...... (N-m + 1) = n! /(N-m )! (Rule 0! = 1 ).
The three numbers below can be the same.
For example, extract two random numbers from an array (1, 2) to combine them.
11
22
12
21
Pair
From the two numbers, we propose that the combination of two numbers is 1.
Arrangement is 2
P (n, m) = n (n-1) (n-2 )...... (N-m + 1) = n! /(N-m )! (Rule 0! = 1 ).
Okay, you have moved yourself in.
N ^ m is OK
Thank you.
I 've been struggling to arrange and combine