필터 지우기
필터 지우기

create function that displays fibonacci series

조회 수: 1 (최근 30일)
Rachel Dawn
Rachel Dawn 2018년 2월 14일
댓글: Walter Roberson 2018년 2월 14일
So, I have four goals here: the user will input the first two numbers of fibonacci series, and the length of the series (n). Fourth goal: function will output 'n' numbers of the Fibonacci series (starting at the two numbers that the user entered).
I've been at this for two hours (youtube videos and all), yet all I've been able to come up with is this:
function FibLength = myFibonacci(n)
if n==0||n==1
FibLength= n;
else
FibLength= myFibonacci(n-2)+myFibonacci(n-1)
end
Which , by the way, just prints out the 'nth' number of the Fibonacci series. Can someone guide me here please?
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 2월 14일
Your line
FibLength= n;
does not adhere to the condition that the user was able to input the first two values of the series.
The first two values of the series are considered to correspond to n = 1 and n = 2 by the way.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by