0% found this document useful (0 votes)
37 views1 page

Open Sees 2

This MATLAB code prompts the user to input a number, defines variables x and y, displays y, then uses a for loop from 1 to the inputted number minus 1 to calculate the Fibonacci sequence by adding the previous two values and assigning it to z, displaying z, reassigning x to y and y to z on each iteration.

Uploaded by

satyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views1 page

Open Sees 2

This MATLAB code prompts the user to input a number, defines variables x and y, displays y, then uses a for loop from 1 to the inputted number minus 1 to calculate the Fibonacci sequence by adding the previous two values and assigning it to z, displaying z, reassigning x to y and y to z on each iteration.

Uploaded by

satyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

clearall;

clc;
prompt='enter from the user';
num=input(prompt);
x=0;
y=1;
disp(y)
for i = 1: (num-1)
z=x+y;
disp(z)
x=y;
y=z;
end

You might also like