You make a very good point about brute-forcing vs solving mathematically. Studying fibonacci is a gateway to learning about recurrence relations, beauty of the golden ratio (phi), interesting relation between Fibonacci and Lukas numbers and how phi keeps cropping up in unexpected places :P
IMO, the main issue with using the direct formula is that there are possibilities of errors creeping at multiple stages due to floating point imprecision.
The matrix solution is beautiful. It is computing the formula mentioned behind the scenes. The only issue with that is again the limited range of machine integers. If we can do it with unlimited precision integers it is a very straight-forward way of solving a recurrence relation efficiently.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You make a very good point about brute-forcing vs solving mathematically. Studying fibonacci is a gateway to learning about recurrence relations, beauty of the golden ratio (phi), interesting relation between Fibonacci and Lukas numbers and how phi keeps cropping up in unexpected places :P
IMO, the main issue with using the direct formula is that there are possibilities of errors creeping at multiple stages due to floating point imprecision.
The matrix solution is beautiful. It is computing the formula mentioned behind the scenes. The only issue with that is again the limited range of machine integers. If we can do it with unlimited precision integers it is a very straight-forward way of solving a recurrence relation efficiently.