Problem 67 Python Cant find fibbonacci number in list

Back to General discussions forum

SirTurtleton     2017-08-06 09:03:28

Hello all, I'm trying to do this problem but got stuck. The result is a ValueError stated that the number I'm looking for is not in the list. I also did check for it manually and confirm that fact. I don't think posting the code here is allowed so here's how I do it:

1.Take iput numbers and write them to a list.

2.Make a list of fibbonaci numbers from 0 to 100.

3.Compare them using index built-in function to find the index of input number.

Here's my method of calculating fibbonacci:

round(((1 + sqrt(5)) / 2) ** n / sqrt(5))

I tried this formula on my computer's shell command but it gives me OverflowError while on this site it doesn't so this raises another question regarding the validity of this particular method. So, my conclusion is that the formula I use here gives incorrect results (due to imprecision, perhaps). My question is that is there any better way to do this?

SirTurtleton     2017-08-06 10:46:40

It's me again. After some more reading, I switched to different method to calculate fibbo numbers and finally solved the problem.

Michael-Levitin     2017-08-23 13:14:24

Hello, good sir The problem states that the number is in the first 1000 fibbonaci numbers (in case you missed it). Aparently none of the languages can handle these numbers as "normal integers" and use scientific representation "1,23e+10". For some unknown reason the number you calculate in 0..1000 run differ from what you need to find, for example: 6.444963554546232e+156 vs 6.444963554546233e+156 (digit by the e). I'm trying now to solve this problem in javascript - my approach is: each fibbonaci number is array of digits, this way I get exact number

Hope that help.

Michael-Levitin     2017-08-23 13:28:49

http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibFormula.html

Quandray     2017-08-23 16:00:09
User avatar

The numbers in the input will be the exact fibonacci numbers.

Please login and solve 5 problems to be able to post at forum