|
[Date Index]
[Thread Index]
[Author Index]
RE: recursive function
- To: mathgroup at yoda.physics.unc.edu
- Subject: RE: recursive function
- From: Joseph G. Mcwilliams <mcwilljg at euler.sfasu.edu>
- Date: Mon, 27 Sep 93 11:43:29 -0500
Thanks to all who responded to my query on the recursive problem, especially Malcolm Crawford and Roberto Sierra.
There were two errors in the original posting. A typo, a>= n*(n-1)/2 should have read a>= n*(n+1)/2, and an outright
error; the above should read a > n*(n+1)/2. The equality causes infinite recursion.
For those interested, a Mathematica code that works is:
f[n_Integer,0] := 1;
f[n_Integer,a_Integer] := 0 /; a<0;
f[n_Integer,a_Integer] :=
f[n,a] = If[ a>n (n+1)/2,
f[n,n (n+1)/2],
f[n-1,a] + f[n-1,a-n]
];
================================================================
Joseph McWilliams
Math/SFASU/Nacogdoches/TX
mcwilljg at euler.sfasu.edu
================================================================
Prev by Date:
Exponents in notebook names
Next by Date:
true size
Previous by thread:
Exponents in notebook names
Next by thread:
Re: Recursive function
|