Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recursive calculations..

Status
Not open for further replies.

player123

Programmer
Mar 29, 2007
1
GB
hi there! i cant figure out how i could program a little function in assembly using the PCSPIM environment.
the function i want to program with recursion is:

func(n) = func(n-1) + (n-1)

this is similiar to the fibonnaci function which is:

fib(n) = fib(n-1) + fib(n-2)

and the code for the fibonnaci can be found here:


how can i change in order to make it work with:

func(n) = func(n-1) + (n-1)

i tried plenty of times but i find it hard! all help will be greately appreciated!
thanks! :)
 
Post one of your better attempts at solving the problem.

The only real trick is making sure that you have an exit condition which stops further recursion.


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top