Fibonacci sequence -a) Write a script to make a  to  sequence vector by using for loop. b) Calculate sum of first ten Fibonacci numbers

조회 수: 4 (최근 30일)
What is Fibonacci sequence a) Write a script to make a to sequence vector by using for loop. b) Calculate sum of first ten Fibonacci numbers

답변 (1개)

Spaceman
Spaceman 2024년 3월 21일
편집: Spaceman 2024년 4월 8일
In mathematics, the Fibonacci sequence is a sequence in which each number is the sum of the two preceding ones.
fib=[0 1];
for n=3:10;
fib(n)=fib(n-1)+fib(n-2);
end
fprintf('The first 10 Fibonacci sequence numbers are: ')
The first 10 Fibonacci sequence numbers are:
disp(fib)
0 1 1 2 3 5 8 13 21 34
Hope this helps, 8 years later...

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by