Post Reply 
Multinomial coefficient
02-15-2015, 05:48 PM
Post: #2
RE: Multinomial coefficient
ok,
after some tries, I simplified all with this:
Code:

EXPORT Multinomial()
BEGIN
local n,k;
input ({n, {k}}, "Multinomial Coefficient", {"n", "k_i list"}, {"Total n", "input {k_i list} with comma"}, {0,0});
// we need integers (also for list)
n:=IP(n); k:=IP(k);

return n!/∏List(k!);
END;

This program accept an integer for "n" and a list with {} for the list of k (like {1,4,4,2}) and give a integer that represent permutations in a multi set...

There are some (ugly) problems:
1. a way to avoid user to input also the {} for the list (it would better to have only something like 1,4,4,2)
2. a control because the sum of k must be equal to n

Any hints are welcome!

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Multinomial coefficient - salvomic - 02-15-2015, 11:59 AM
RE: Multinomial coefficient - salvomic - 02-15-2015 05:48 PM
RE: Multinomial coefficient - parisse - 02-15-2015, 07:44 PM
RE: Multinomial coefficient - salvomic - 02-15-2015, 08:20 PM
RE: Multinomial coefficient - salvomic - 02-15-2015, 09:25 PM



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