6 replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/

# Python 3, 93 91

Thanks to DennisDennis and FryAmTheEggmanFryAmTheEggman.

f=lambda x:0**x or x*f(x-1)
def g(n,k):
r=f(n)
for i in k:r//=f(i)
return r//f(n-sum(k))


n as integer, k as iterable.

Ungolfed:

import functools #cache

@functools.lru_cache(maxsize=None) #cache results to speed up calculations
def factorial(x):
if x <= 1: return 1
else: return x * factorial(x-1)

def multinomial(n, k):
ret = factorial(n)
for i in k: ret //= factorial(i)
km = n - sum(k)
return ret//factorial(km)


# Python 3, 93 91

Thanks to Dennis and FryAmTheEggman.

f=lambda x:0**x or x*f(x-1)
def g(n,k):
r=f(n)
for i in k:r//=f(i)
return r//f(n-sum(k))


n as integer, k as iterable.

Ungolfed:

import functools #cache

@functools.lru_cache(maxsize=None) #cache results to speed up calculations
def factorial(x):
if x <= 1: return 1
else: return x * factorial(x-1)

def multinomial(n, k):
ret = factorial(n)
for i in k: ret //= factorial(i)
km = n - sum(k)
return ret//factorial(km)


# Python 3, 93 91

Thanks to Dennis and FryAmTheEggman.

f=lambda x:0**x or x*f(x-1)
def g(n,k):
r=f(n)
for i in k:r//=f(i)
return r//f(n-sum(k))


n as integer, k as iterable.

Ungolfed:

import functools #cache

@functools.lru_cache(maxsize=None) #cache results to speed up calculations
def factorial(x):
if x <= 1: return 1
else: return x * factorial(x-1)

def multinomial(n, k):
ret = factorial(n)
for i in k: ret //= factorial(i)
km = n - sum(k)
return ret//factorial(km)

5 added 202 characters in body

# Python 3, 9393 91

Thanks to Dennis and FryAmTheEggman.

fromf=lambda mathx:0**x import*
f=factorialor x*f(x-1)
def g(n,k):
r=f(n)
for i in k:r//=f(i)
return r//f(n-sum(k))


n as integer, k as iterable.

Ungolfed:

import functools #reduce#cache
import
@functools.lru_cache(maxsize=None) math#cache #factorial
importresults operatorto #mulspeed up calculations
def multinomialfactorial(n, kx):
kmif =x n<= -1: sum(k)return 1
k.appendelse: return x * factorial(kmx-1)

def multinomial(n, k):
numerator  ret = math.factorial(n)
denominatorfor =i functools.reduce(operator.mul,in (math.k: ret //= factorial(i)
for i in k))km #product= ofn iterable- sum(k)
return numeratorret//denominatorfactorial(km)


# Python 3, 93

from math import*
f=factorial
def g(n,k):
r=f(n)
for i in k:r//=f(i)
return r//f(n-sum(k))


n as integer, k as iterable.

Ungolfed:

import functools #reduce
import math #factorial
import operator #mul
def multinomial(n, k):
km = n - sum(k)
k.append(km)
numerator = math.factorial(n)
denominator = functools.reduce(operator.mul, (math.factorial(i) for i in k)) #product of iterable k
return numerator//denominator


# Python 3, 93 91

Thanks to Dennis and FryAmTheEggman.

f=lambda x:0**x or x*f(x-1)
def g(n,k):
r=f(n)
for i in k:r//=f(i)
return r//f(n-sum(k))


n as integer, k as iterable.

Ungolfed:

import functools #cache

@functools.lru_cache(maxsize=None) #cache results to speed up calculations
def factorial(x):
if x <= 1: return 1
else: return x * factorial(x-1)

def multinomial(n, k):
ret = factorial(n)
for i in k: ret //= factorial(i)
km = n - sum(k)
return ret//factorial(km)

4 deleted 29 characters in body

# Python 3, 11693

from functools import*
from math import*
f=factorial
def g(n,k):
r=f(n)
for i in k:r//=f(i)
return r//f(n-sum(k))


n as integer, k as iterable.

Ungolfed:

import functools #reduce
import math #factorial
import operator #mul
def multinomial(n, k):
km = n - sum(k)
k.append(km)
numerator = math.factorial(n)
denominator = functools.reduce(operator.mul, (math.factorial(i) for i in k)) #product of iterable k
return numerator//denominator


# Python 3, 116

from functools import*
from math import*
f=factorial
def g(n,k):
r=f(n)
for i in k:r//=f(i)
return r//f(n-sum(k))


n as integer, k as iterable.

Ungolfed:

import functools #reduce
import math #factorial
import operator #mul
def multinomial(n, k):
km = n - sum(k)
k.append(km)
numerator = math.factorial(n)
denominator = functools.reduce(operator.mul, (math.factorial(i) for i in k)) #product of iterable k
return numerator//denominator


# Python 3, 93

from math import*
f=factorial
def g(n,k):
r=f(n)
for i in k:r//=f(i)
return r//f(n-sum(k))


n as integer, k as iterable.

Ungolfed:

import functools #reduce
import math #factorial
import operator #mul
def multinomial(n, k):
km = n - sum(k)
k.append(km)
numerator = math.factorial(n)
denominator = functools.reduce(operator.mul, (math.factorial(i) for i in k)) #product of iterable k
return numerator//denominator

3 fixed bug with km
2 added 20 characters in body
1