Post Reply 
Dice probabilities
05-03-2024, 01:08 PM
Post: #36
RE: Dice probabilities
(05-02-2024 02:46 PM)John Keith Wrote:  ... Now, typing 6 9 MNOM 14 GET will return your result.

Code:
function MNOM(m, n) -- ((x^m-1)/(x-1))^n coefficients
    local P = setmetatable({1}, {__index = function(t,k) return 0 end})
    for i=1,n do
        for j=#P+m-1,1,-1 do
            for k=j-m+1,j-1 do P[j]=P[j]+P[k] end
        end
    end
    return P
end

lua> pprint(MNOM(3,5))
{ 1, 5, 15, 30, 45, 51, 45, 30, 15, 5, 1 }

lua> MNOM(6,9)[14]
145899
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Dice probabilities - dm319 - 04-29-2024, 04:23 PM
RE: Dice probabilities - Thomas Klemm - 04-29-2024, 04:55 PM
RE: Dice probabilities - Allen - 04-30-2024, 11:19 AM
RE: Dice probabilities - dm319 - 04-29-2024, 05:49 PM
RE: Dice probabilities - Thomas Klemm - 04-29-2024, 06:07 PM
RE: Dice probabilities - David Hayden - 04-30-2024, 07:30 PM
RE: Dice probabilities - Albert Chan - 04-30-2024, 08:26 PM
RE: Dice probabilities - dm319 - 04-30-2024, 09:57 PM
RE: Dice probabilities - dm319 - 04-29-2024, 07:14 PM
RE: Dice probabilities - Albert Chan - 04-29-2024, 09:22 PM
RE: Dice probabilities - dm319 - 04-30-2024, 10:07 PM
RE: Dice probabilities - Albert Chan - 05-01-2024, 11:14 AM
RE: Dice probabilities - dm319 - 04-29-2024, 07:22 PM
RE: Dice probabilities - Gil - 04-29-2024, 10:36 PM
RE: Dice probabilities - Thomas Klemm - 04-30-2024, 12:27 AM
RE: Dice probabilities - John Keith - 04-30-2024, 10:00 PM
RE: Dice probabilities - Thomas Klemm - 04-30-2024, 12:40 AM
RE: Dice probabilities - Thomas Klemm - 04-30-2024, 06:43 AM
RE: Dice probabilities - Thomas Klemm - 04-30-2024, 08:06 AM
RE: Dice probabilities - Albert Chan - 04-30-2024, 10:59 AM
RE: Dice probabilities - Dave Britten - 04-30-2024, 12:00 PM
RE: Dice probabilities - Thomas Klemm - 04-30-2024, 05:11 PM
RE: Dice probabilities - Dave Britten - 04-30-2024, 05:58 PM
RE: Dice probabilities - Thomas Klemm - 04-30-2024, 06:04 PM
RE: Dice probabilities - Thomas Klemm - 04-30-2024, 06:25 PM
RE: Dice probabilities - Dave Britten - 04-30-2024, 07:24 PM
RE: Dice probabilities - Thomas Klemm - 04-30-2024, 09:10 PM
RE: Dice probabilities - Thomas Klemm - 05-01-2024, 03:32 AM
RE: Dice probabilities - Thomas Klemm - 05-01-2024, 04:26 AM
RE: Dice probabilities - Thomas Klemm - 05-01-2024, 04:41 AM
RE: Dice probabilities - John Keith - 05-01-2024, 06:56 PM
RE: Dice probabilities - Thomas Klemm - 05-01-2024, 05:54 AM
RE: Dice probabilities - Thomas Klemm - 05-01-2024, 08:45 PM
RE: Dice probabilities - John Keith - 05-02-2024, 02:46 PM
RE: Dice probabilities - Albert Chan - 05-03-2024 01:08 PM
RE: Dice probabilities - Thomas Klemm - 05-03-2024, 01:20 AM



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