1 a) MARIE Program for calculating Fib(n)

Added on - 27 Dec 2019

  • 6

    Pages

  • 665

    Words

  • 105

    Views

  • 0

    Downloads

Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 3 of 6 pages
Computer organisation &architecture
TABLE OF CONTENTSTask.................................................................................................................................................31)......................................................................................................................................................3a) MARIE Program for calculating Fib(n)..................................................................................3b) Maximum value of n for getting correct results.....................................................................42)......................................................................................................................................................4Computer instructions:.................................................................................................................43)......................................................................................................................................................5Codes for implementation: A= (B + C) * (D – E).......................................................................52
TASK1)a) MARIE Program for calculating Fib(n)Following is the program designed for calculating the value of Fib(n), where n is the user inputprovided during execution.For instance, when n = 7, the value is 13.Hence, the below mentioned program is designed for getting the respective values in MARIEsimulation:N= input('Pick a number\n');Fib=zeros(1,N);Fib(1)=1;Fib(2)=1;k=3while k<=NFib(k)= Fib(k-2)+ Fib(k-1);k= k+1;endfprintf('The Fibonacci sequence to %d terms is \n', N);fprintf('%g',Fib);fprintf('\n');Following is the output of the program when simulated:Pick a number14The Fibonacci sequence to 14 terms is1 1 2 3 5 8 13 21 34 55 89 144 233 3773
desklib-logo
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document