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

    Aruwin

    Aruwin

    @aruwin-WQ7eeu
    Updated: Oct 23, 2024
    Views: 936
    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);
    }
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Home Channels Search Login Register