logo

1 a) MARIE Program for calculating Fib(n)

6 Pages665 Words299 Views
   

Added on  2019-12-28

1 a) MARIE Program for calculating Fib(n)

   Added on 2019-12-28

ShareRelated Documents
Computer organisation &architecture
1 a) MARIE Program for calculating Fib(n)_1
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
1 a) MARIE Program for calculating Fib(n)_2
TASK 1)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 number14 The Fibonacci sequence to 14 terms is 1 1 2 3 5 8 13 21 34 55 89 144 233 3773
1 a) MARIE Program for calculating Fib(n)_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Computer Organization and Architecture Assignment 2: MARIE and ISA
|9
|529
|59

Computer Organization and Architecture - Assignment
|10
|718
|42

Calculation of the Fib (n) with MARIE
|9
|583
|341

MARIE and ISA: Answers to Questions 1-3
|9
|811
|325

The Essentials of Computer Organization and Architecture
|7
|769
|65

Introduction to MARIE Programming
|10
|409
|98