blob: 4c6a66f41605780f34e69644bbd6a2aa65a90fcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
def permutation_coefficient(n, k):
P = [[0 for i in range(k + 1)]
for j in range(n + 1)]
for i in range(n + 1):
for j in range(min(i, k) + 1):
if (j == 0):
P[i][j] = 1
else:
P[i][j] = P[i - 1][j] + (
j * P[i - 1][j - 1])
if (j < k):
P[i][j + 1] = 0
return P[n][k]
|