From: Jon Schoenfield (jonscho(AT)hiwaay.net) Subject: Recursive formula for A007747 Date: Mon, 7 May 2007 05:18:00 -0500 Let f(K, L, S, X) be the number of distinct, non-decreasing sequences of K integers such that - the smallest is at least L - the sum is exactly S - for J = 1, 2, ... , K, the sum of the last J integers does not exceed X + (X - 2) + (X - 4) + ... + (X + 2 - 2J) = J * (X + 1 - J) Then A007747(n) = f(n + 1, 0, n * (n + 1), 2 * n) and f(K, L, S, X) can be computed recursively as follows: If K > 1 And L <= S / K <= X + 1 - K Then f(K, L, S, X) = Sum(i = L..[S/K], f(K - 1, i S - i, X)) ElseIf K = 1 And L <= S <= X Then f(K, L, S, X) = 1 Else f(K, L, S, X) = 0 End If Storing the results as I go (so as not to have to recompute various terms repeatedly) I quickly get 0 1 1 2 2 5 3 16 4 59 5 247 6 1111 7 5302 8 26376 9 135670 10 716542 11 3868142 12 21265884 13 118741369 14 671906876 15 3846342253 16 22243294360 17 129793088770 18 763444949789 19 4522896682789 20 26968749517543 21 161750625450884 22 975311942386969 23 5909549998347426 24 35966989049703190 25 219805620101524692 26 1348411202206288080 27 8301060310442081332 28 51270095697195675623 29 317626571945589273005 30 1973349964225787873325 31 12292687428076449472982 32 76766763661318262944980 33 480527225019636428107051 34 3014543596124141517822611 35 18950882981333834931767138 36 119369029178646121247420432 37 753290091364020354392689860 38 4762104127020274580556624150 39 30155216974251399477413628177