write a MATLAB program to determine the n^th number in the Fibonacci sequence
Afficher commentaires plus anciens
F0 = 0; F1 = 1; Fn+2 = Fn+1 + Fn; n 0
1. By default MATLAB will use double precision for all numeric values unless you specify otherwise. For which n will Fn over ow? What does your program report as Fn in this case?
2. Modify your program to force the use of unsigned 32-bit integers. You can do this by modifying n with n = uint32(n); F1 = uint32(0); F2 = uint32(1);. Any variables calculated using only unsigned 32-bit integer variables will become unsigned 32-bit integer variables themselves unless you specify otherwise. For which n will Fn overflow? What does your program report as Fn in this case?
Réponses (2)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!