presumably f is just a stand in for a more complex recusive function
–
Scott WeinsteinAug 3 '09 at 23:22

@Scott Weinstein The question is the question. If am going to get downvoted for answering the question as it was posted, so be it.
–
Sinan ÜnürAug 3 '09 at 23:26

assuming that column A is going to be sequential then your example works.
–
Stan R.Aug 3 '09 at 23:29

Scott, the question doesn't imply that at all. If the question is intended to mean, "How can I perform a general recursive function in Excel?" than, well, that's what the question should say. The less snarky version of Sinan's (completely correct) answer is: f(n + 1) = (n^2 + n)/2
–
WCWedinAug 3 '09 at 23:31

Excel has something called Array Formulas, which allows a function to return a set of values. You can read more about them here. These will effectively let you write, with some creativity, analogs to recursive algorithms. Array formulas must be entered in using Shift-Ctrl-Enter.

To answer your question, have an array function return 1 through n-1, and wrap it in a sum. Here, Indirect creates a reference, and A1 holds n:

which means we can generalize the function to f(n)=1+2+...+n=n*(n-1)/2 for n>1 and f(n)=0 otherwise.

The resulting Excel formula can then be written as =IF(A5>1;A5*(A5-1)/2);0), assuming A5 contains n.

Obviously, if your formula is more complex than the one you gave, it may become quite a bit harder, and it may be a lot quicker and easier to just write a user defined function like the one suggested by Scott and then use that.