Finding Fibonacci Numbers

Hello, I know this has been a while since my prior post and I have not gotten out any video yet doing a tutorial on a program I did. I have been having a busy week at university and I've been rather skeptical on the program I was originally going to use for the tutorial, as it's overly complicated for its results. I may actually use this program for my tutorial as it would be easier to explain and is less complicated. For now I'll continue with this program. You may find the program here on Github.

I guess I won't have to give much explanation on the Fibonacci sequence. Basically, it's a sequence where a term is the sum of the two prior terms. This program, when inputted a number n, will return the nth term in the Fibonacci sequence. It works by making the a list of all terms within the Fibonacci sequence from 0 to n and returning the last item in the list. 

As its does the regular method, it works accurately for even large numbers and should work up to the limits of your computer's memory or the limit of arrays in python. The largest term I did was 500,000. It took several minutes and the result is 2.95556 * 10 ^ 104,493 (give or take a magnitude of 10), which takes 29 pages in Word and took way more than the entire screen could show.

A small snippet of the 500,000th term in the Fibonacci sequence. IDLE could barely handle scrolling through.

I've found online another way of finding the nth term without needing to find any other term in the sequence. This version uses the Golden Ratio, φ, which is calculated as (1 + 5) / 2. The program uses the equation (φ^n - (1 - φ)^n) / 5. I have to round this to remove a bunch of zeros.

My calculation of φ seems to match with the actual ratio up the the 11th decimal point. It will be accurate until the 70th place, which is 190,392,490,709,135. After that, it will be larger by 1in the next term than what it should be. After that, the gap between what this equation and what the prior method get will become more and more prominent each term. The equation's actual limit is the 1474th place, which is about 4.99255 * 10 ^ 308, give or take a magnitude of 10. Anything past that will give an overflow error.

This was an easy program to do. I actually had no need to do it, my programming class was doing something different. This was basically done because my Calculus class went over the Fibonacci sequence. Hopefully I will get something else done in a few days and will likely make a video tutorial for this soon. Perhaps I try to do more with the Fibonacci sequence, such as working with Pisano Periods. Until then, see you next time!

Comments

Popular posts from this blog

Version 2:The Not-So Barebones Clicker

A Prime Factorization Algorithm that Uses a Text File

Aesthetico Ultimate Designer - A Python Turtle Program