use octave or MATLAB as programs to code. do not usedisp or num2str. also, do not use break or continuestatements.


2. In this problem we will modify the code for the Fibonacci sequence developed in class to give more output. Recall that the Fibonacci numbers are 0,1,1,2,3,5,8,… and can be defined recursively for n > 3 as Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2) with Fibonacci(1) = 0 and Fibonacci(2)=1. Write a program that calls a function get-positive integer which should • keep prompting the user and giving error messages until a positive integer is entered • return the resulting value The main program should then call a recursive function fibonacci which should take in an integer n for which Fibonacci number to compute and an integer indicating how many times (including the current call) the function has been called upon entry, print a debug message displaying the values of the input variables call itself recursively as needed to calculate the specified Fibonacci number return the requested Fibonacci number and the counter of the number of calls to the fibonacci function The main program should then display the final result. Hint: Remember how to call a function that returns two variables. Sample output: Enter a positive integer: -2 Invalid entry – 2 Enter a positive integer: 3.5 Invalid entry 3.5 Enter a positive integer: 5 Fibonacci: Enter on call 1 to compute Fibonacci( 5 ) Fibonacci: Enter on c 2 to compute Fibonacci (4) Fibonacci: Enter on 3 to compute Fibonacci( 3 ) Fibonacci: Enter on to compute Fibonacci (2 Fibonacci: Enter to compute Fibonacci Fibonacci: Enter on to compute Fibo Fibonacci: Enter on call to compute Fibonaccid Fibonacci: Enter on 8 to compute Fibon Fibonacci: Enter on call 9 to compute Fibonacci Fibonacci number 5 18 3 voonWN call ашpe output Enter a positive integer: -2 Invalid entry -2 Enter a positive integer: 3.5 Invalid entry 3.5 Enter a positive integer: 5 Fibonacci: Enter on call 1 to compute Fibonacci( 5 ) Fibonacci: Enter on call 2 to computa Fibonacci( 4 ) Fibonacci: Enter on call 3 to compute Fibonacci( 3 ) Fibonacci: Enter on call 4 to compute Fibonacci ( 2 ) Fibonacci: Enter on call 5 to compute Fibonacci( 1 ) Fibonacci: Enter on call 6 to compute Fibonacci( 2 ) Fibonacci: Enter on call 7 to compute Fibonacci (3) Fibonacci: Enter on call 8 to compute Fibonacci (2) Fibonacci: Enter on call 9 to compute Fibonacci(1) Fibonacci number 5 is 3 Below is a figure that might help explain the above sample output. Fibon Pibonacci Fibonacci Pibenacak? bonado Show transcribed image text 2. In this problem we will modify the code for the Fibonacci sequence developed in class to give more output. Recall that the Fibonacci numbers are 0,1,1,2,3,5,8,… and can be defined recursively for n > 3 as Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2) with Fibonacci(1) = 0 and Fibonacci(2)=1. Write a program that calls a function get-positive integer which should • keep prompting the user and giving error messages until a positive integer is entered • return the resulting value The main program should then call a recursive function fibonacci which should take in an integer n for which Fibonacci number to compute and an integer indicating how many times (including the current call) the function has been called upon entry, print a debug message displaying the values of the input variables call itself recursively as needed to calculate the specified Fibonacci number return the requested Fibonacci number and the counter of the number of calls to the fibonacci function The main program should then display the final result. Hint: Remember how to call a function that returns two variables. Sample output: Enter a positive integer: -2 Invalid entry – 2 Enter a positive integer: 3.5 Invalid entry 3.5 Enter a positive integer: 5 Fibonacci: Enter on call 1 to compute Fibonacci( 5 ) Fibonacci: Enter on c 2 to compute Fibonacci (4) Fibonacci: Enter on 3 to compute Fibonacci( 3 ) Fibonacci: Enter on to compute Fibonacci (2 Fibonacci: Enter to compute Fibonacci Fibonacci: Enter on to compute Fibo Fibonacci: Enter on call to compute Fibonaccid Fibonacci: Enter on 8 to compute Fibon Fibonacci: Enter on call 9 to compute Fibonacci Fibonacci number 5 18 3 voonWN call
ашpe output Enter a positive integer: -2 Invalid entry -2 Enter a positive integer: 3.5 Invalid entry 3.5 Enter a positive integer: 5 Fibonacci: Enter on call 1 to compute Fibonacci( 5 ) Fibonacci: Enter on call 2 to computa Fibonacci( 4 ) Fibonacci: Enter on call 3 to compute Fibonacci( 3 ) Fibonacci: Enter on call 4 to compute Fibonacci ( 2 ) Fibonacci: Enter on call 5 to compute Fibonacci( 1 ) Fibonacci: Enter on call 6 to compute Fibonacci( 2 ) Fibonacci: Enter on call 7 to compute Fibonacci (3) Fibonacci: Enter on call 8 to compute Fibonacci (2) Fibonacci: Enter on call 9 to compute Fibonacci(1) Fibonacci number 5 is 3 Below is a figure that might help explain the above sample output. Fibon Pibonacci Fibonacci Pibenacak? bonado
Expert Answer
Answer to use octave or MATLAB as programs to code. do not use disp or num2str. also, do not use break or continue statements. …