And it works for numbers that are not Fibonacci numbers - express the original as a sum of Fibonacci numbers, do the conversion for each separately, and add them up. Here's an example from Peteris Krumins' coding blog:
For example, how many kilometers are there in 100 miles? Number 100 can be expressed as a sum of Fibonacci numbers 89 + 8 + 3. Now, the Fibonacci number following 89 is 144, the Fibonacci number following 8 is 13 and the Fibonacci number following 3 is 5. Therefore the answer is 144 + 13 + 5 = 162 kilometers in 100 miles. This is less than 1% off from the precise answer, which is 160.93 km.And if you're interested, that blog also explains why it works.
No comments:
Post a Comment