Goal is to find nth Fibonacci number. What is Fibonacci series? It can be define
ID: 3621893 • Letter: G
Question
Goal is to find nth Fibonacci number. What is Fibonacci series? It can be defined by the following equations:
Fn= Fn-1+ Fn-2 where Fn is the nth Fibonacci number.
F0 = 0
F1 = 1
The sequence thus is 0,1,1,2,3,5,8,13,21,34,55…….
Example:
Which Fibonacci number do you want : 5
Output: Number is 5 and the series is 0,1,1,2,3,5
User should be asked for positive integers.
PLEASE NOTE THAT: the output must show the whole series such as shown in the example where the program asks for an integer, user puts in 5, and the output is 0, 1, 1, 2, 3, 5 and not just 5.
Thank you!!!
will rate lifesaver!!!
Explanation / Answer
Dear, Here is the code fib: addi $sp, $sp, -12 sw $ra, 8($sp) sw $s0, 4($sp) addi $v0, $zero, 1 beq $a0, $zero, fin addi $t0, $zero, 1 beq $a0, $t0, fin addi $a0, $a0, -1 sw $a0, 0($sp) jal fib lw $a0, 0($sp) addi $a0, $a0, -1 add $s0, $v0, $zero jal fib add $v0, $v0, $s0 fin: lw $s0, 4($sp) lw $ra, 8($sp) addi $sp, $sp, 12 jr $ra Hope this will help you..
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.