diff options
Diffstat (limited to 'progs/a869.py')
-rw-r--r-- | progs/a869.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/progs/a869.py b/progs/a869.py new file mode 100644 index 0000000..4c6a66f --- /dev/null +++ b/progs/a869.py @@ -0,0 +1,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]
\ No newline at end of file |