Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Permutations: sequences of elements of a given set, each element can occur only

ID: 3764825 • Letter: P

Question

Permutations: sequences of elements of a given set, each element can occur only once.

Permutations of n elements = n!

Permutations of k elements out of n elements: P(n,k)= n!/ (n-k)!

Explanation: The first element can be chosen in n different ways.

Once chosen, the second element can be chosen among (n-1) elements.
Thus two elements can be chosen in n(n-1) ways.
The choices for the third element are among n-2 elements.
At the end, the choice for the k-th element is made among n-k+1 elements.
Hence the number of permutations is n(n-1)(n-2)….(n-k+1) = n!/(n-k)!

For this problem, create a function which evaluates a word with NO REPEATS and calculates all possible permutations. It should be similar to the following output:
Input word: tail
4
4
8
24

Explanation / Answer

You're looking for the permutations formula:

In your case, you have 9 entries and you want to choose all of them, that's 9P9 = 9! = 362880

You can find a PHP algorithm to permutate in recipe 4.26 of O'Reilly's "PHP Cookbook".

Copied in from O'Reilly:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote