Write an MIPS procedure of calculating the n-th term of the Fibonacci sequence F (n)

Someone please help me by showing how to do this.
Write an MIPS procedure of calculating the n-th term of the Fibonacci sequence F (n).
F(n) is defined as below:
When n = 0, F (n) = 0
When n = 1, F (n) = 1
Otherwise, F (n) = F (n-1) + F (n-2)
however,you have to use following algorithm which is clear but very inefficient:
int fib(int n) {
if (n == 0)
return 0;
else if (n == 1)
return 1;
else
return fib(n-1) + fib(n-2);
}

Replies

You are reading an archived discussion.

Related Posts

i have a wireless hotspot that whenever i connect to it it keep assigning different ip addresses each time am connected. do anyone have idea on how to use a...
How to install windows xp on core i 5 processor laptop.
hi all... i am new in fuzzy logic field. can anyone tell me how to write fuzzy rules and membership functions in matlab...... Thanks in advance
Everest may be the tallest. However it is not the deadliest. It comes a low sixth in this category. It is interesting that four of those above Everest are in...
Two great civil engineering infrastructures celebrate anniversaries. https://www.wired.com/thisdayintech/...+wired/index+(Wired:+Index+3+(Top+Stories+2)) https://www.bbc.co.uk/news/uk-england-birmingham-18094742