Post Reply 
Dividing factorials on 15C CE
01-10-2024, 08:38 PM
Post: #21
RE: Dividing factorials on 15C CE
(01-10-2024 07:54 PM)Thomas Klemm Wrote:  I just hope we clarified that David was not talking about the division 49/2 but about (1 * 50/1 * 49)/2.
Which is indeed an integer.

I understood it in that way too, but I already knew this property of the algorithm.


Now about my previous comment:

(01-09-2024 04:38 PM)J-F Garnier Wrote:  
(01-09-2024 01:23 AM)Thomas Klemm Wrote:  P(50, 45) = 1 * 50 * 49 * 48 * 47 * 46

Code:
def perm(n, k):
    p = 1
    while n > k:
        p *= n
        n -= 1
    return p

It seems to me a singular way to compute permutations... Smile

Nobody responded to my remark, and I'm not sure Thomas fully understood it.
My point is that Perm(50, 45) is NOT 1 * 50 * 49 * 48 * 47 * 46 . This is Perm(50,5).
And so the Python perm code Thomas posted is wrong.

Also, the Python comb code is very inefficient to compute simple values such as comb(50,5), that the code computes as:
comb(50,5) = 1 * 50/1 * 49/2 * 48/3 * 47/4 * 46/5 * 45/6 * 44/7 * 43/8 * ... * 7/44 * 6/45
This kills the claim of avoiding rounding errors.
Instead it should just be:
comb(50,5) = 1 * 50/1 * 49/2 * 48/3 * 47/4 * 46/5

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Dividing factorials on 15C CE - philiph - 01-06-2024, 10:38 AM
RE: Dividing factorials on 15C CE - Werner - 01-06-2024, 02:13 PM
RE: Dividing factorials on 15C CE - Werner - 01-07-2024, 09:03 AM
RE: Dividing factorials on 15C CE - Johnh - 01-06-2024, 07:23 PM
RE: Dividing factorials on 15C CE - Johnh - 01-10-2024, 09:22 AM
RE: Dividing factorials on 15C CE - jthole - 01-07-2024, 09:29 AM
RE: Dividing factorials on 15C CE - J-F Garnier - 01-10-2024 08:38 PM



User(s) browsing this thread: 1 Guest(s)