Restricted Integer Partitions Pk(n) means the amount of partitions of n into exactly k parts. Given n and k, calculate Pk(n).


  Tip: Pk(n) = Pk(n−k) + Pk−1(n−1), with initial values p0(0) = 1 and pk(n) = 0 if n ≤ 0 or k ≤ 0. [Wiki]


Examples

n    k    Ans
1    1    1
2    2    1
4    2    2
6    2    3
10   3    8


Rules


General code-golf rules apply.
Swift, 76 73 bytes

func P(_ n:Int,_ k:Int)-&gt;Int{return n*k&gt;0 ?P(n-k,k)+P(n-1,k-1):n==k ?1:0}

Try it online!

Explanation
How does the code structurally work?
First of all, we define our function P, with two integer parameters n and k, and give it a return type of Int, with this piece of code: func P(_ n:Int,_ k:Int)-&gt;Int{...}. The cool trick here is that we tell the compiler to ignore the names of the parameters, with _ followed by a space, which saves us two bytes when we call the function. return is obviously used to return the result of our nested ternary described below.
Another trick I used was n*k&gt;0, which saves us a couple of bytes over n&gt;0&amp;&amp;k&gt;0. If the condition is true (both the integers are still higher than 0), then we recursively call our function with n decremented by k as our new n and k stays the same, and we add the result of P() with n and k decremented by 1. If the condition is not true, we return either 1 or 0 depending on whether n is equal to k.
How does the recursive algorithm work?
We know that the first element of the sequence is p0(0), and so we check that both integers are positive (n*k&gt;0). If they are not higher than 0, we check if they are equal (n==l ?1:0), here being two cases:

There is exactly 1 possible partition, and thus we return 1, if the integers are equal.

There are no partitions if one of them is already 0 and the other is not.


However, if both are positive, we recursively call P twice, adding the results of P(n-k,k) and P(n-1,k-1). And we loop again until n has reached 0.

* Note: The spaces cannot be removed.