In the first test case of example 1 (N=7, D=1) the 10 possible distributions are:
1 1 1 1 1 1 1
1 1 1 1 1 2
1 1 1 1 3
1 1 1 2 2
1 2 2 2
1 1 2 3
1 3 3
2 2 3
3 4
7
1 2 4 is not a valid distribution, because the difference between 1 and 4 is greater than 2.
In the second test case of example 1 (N=7, D=2) the only possible distribution is 2 2 3. 3 4 fails because its first term is not divisible by 2.
In the third test case of example 1 (N=2, D=4) no distribution exists.