From 97f112131dd8d04229f89ecb26776de2bc561f6e Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sun, 28 Oct 2018 13:23:03 +0100 Subject: [PATCH] Calculate sterling numbers --- school/di-ma/uebung/02/st.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/school/di-ma/uebung/02/st.py b/school/di-ma/uebung/02/st.py index b04a7e3..e17a49d 100644 --- a/school/di-ma/uebung/02/st.py +++ b/school/di-ma/uebung/02/st.py @@ -22,15 +22,20 @@ def s(n,k): def S(n, k): if n == k: - return 1 + return " S_{" + n + "," + k + "} " + # return 1 elif k == 1: - return 1 + return " S_{" + n + "," + k + "} " + # return 1 elif k == 0: - return 0 + return " S_{" + n + "," + k + "} " + # return 0 elif n < k: - return 0 + return " S_{" + n + "," + k + "} " + # return 0 else: - return S(n-1,k-1) + k * S(n-1,k) + return " S_{" + str(n-1) + "," + str(k-1) + "} + " + str(k) + " * S_{" + str(n-1) + "," + str(k) + "} " + # return S(n-1,k-1) + k * S(n-1,k) -# print(S(9,5)) -print(p(10,4)) +print(S(5,3)) +# print(p(10,4))