The simple counts. I can make Mathematica do them (using CS notation, P(n,r) and C(n,r)). Is there a reason that these don’t exist as simple built-in functions (or can I just not find them)?
The function C is called Binomial in Mathematica. The function P does not appear to be pre-installed, but you can define it yourself:
P[n_, r_] := n!/(n - r)!
Binomial makes sense.
That’s what I figured for Perm.
Thanks.
You might also take a look at Pochhammer and FactorialPower.
That doesn’t answer the original question, which is one I have as well. Why aren’t these native to Mathematica?
Binomial (which counts combinations) and Pochhammer (which counts permutations) are both Mathematica system functions.
In[112]:= Pochhammer[3, 2]
Out[112]= 12
But 3P2 = 6, not 12
Check the reference page for Pochhammer to see how the arguments get used. In particular, to map to permutations (n,k), one would use Pochhammer[k,n-k+1].
Thanks, Daniel, I hadn’t thought to do that.
But for my own convenience, I will create a user-defined function as suggested by
Gianluca.
In my humble opinion, permutations (n,k) or nPk may be calculated by Pochhammer[n-k+1, k], not by Pochhammer[k,n-k+1]. For example, 5P2 is 5!/(5-2)! = 5!/3! = 5x4=20. Pochhammer[4,2] gives 20. Pochhammer[2,4] results in 120. I am just learning ropes in Mathematica and my math skills are quite rusty. Please, take my words with a grain of salt.
Sang