|
![](/i/fill.gif) |
>> The function definition can use the standard Excel =IF(,,) function
>> to make a conditional result to stop the recursion.
>> The rest would be provided by the standard mechanism of function calls.
>
> I think Andy was talking about how Excel would support recursion, not
> how a user would implement a recusive function. Currently Excel would
> throw a "Circular reference" error.
...unless you have checked the "Iteration" box under
Options->Calculation. It's possible to then write a recursive formula,
the classic example of course is factorial:
Cell A2: =IF(A1="",IF(A2<=1,A2,A2-1),A1+1)
Cell A3: =IF(A1="",A2*A3,1)
You can then type a number in cell A1, hit enter and then delete the
number (the formula in A2 restarts the iteration when A1 goes empty).
Cell A3 will then give you the answer.
Post a reply to this message
|
![](/i/fill.gif) |