How would I make my for loop more accurate.
조회 수: 1 (최근 30일)
이전 댓글 표시
a = 0;
b = 1;
c = 0;
d = 1;
for k = 1:700
c = a + b;
a = b;
b = c;
d = [d c];
end
format long
d(700) %>>> 8.747081495575278e+145
fibonacci(700) %>>> 8.747081495575285e+145
I believe the function fibonacci(n) has the correct number.
How does the function fibonacci have a more accurate number?
댓글 수: 0
답변 (1개)
Walter Roberson
2019년 2월 10일
fibonnaci() is a function in the Symbolic Toolbox. It calculates the numbers as indefinite precision software integers, and then converts the result to double.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!