필터 지우기
필터 지우기

How to make a matrix of fibonacci values and the corresponding number of elements to get 5702887?

조회 수: 1 (최근 30일)
Making a matrix of fibonacci values and the corresponding number of elements to get 5702887? Using a while loop I am not sure where to begin. I was given that the output must be 5702887 and there should be 26-39 elements in the vector and that I must use a while loop
  댓글 수: 4
James Tursa
James Tursa 2015년 11월 25일
Do you know how to calculate Fibonacci numbers? Do you know how to write a while loop? Do you know how to iteratively assign values to the elements of a vector in a loop? That is where to begin.
Michelle S
Michelle S 2015년 11월 25일
Yes I know how to calculate them and how a while loop works, I am just confused about the programming

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

답변 (1개)

Walter Roberson
Walter Roberson 2015년 11월 25일
last_generated = 0;
while last_generated < 5702887
generate another one
last_generated = generated value
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2015년 11월 26일
Look at this example:
results = []; currentvalue = 0;
while currentvalue < 5
thisvalue = rand();
results(end+1) = thisvalue;
currentvalue = currentvalue + thisvalue;
end
length(results)

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by