Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's wrong with my Fibonacci sequence generator?
    primarykey
    data
    text
    <p>I'm trying to solve <a href="http://projecteuler.net/problem=25" rel="nofollow">Problem #25 on Project Euler</a>. Here's what I've got so far:</p> <pre><code>def fibonacci(length): fibs = [0,1] while length &gt; len(fibs): fibs.append(fibs[-1] + fibs[-2]) return fibs fibs = fibonacci(5000) for i in fibs: if len(str(i)) &gt; 1000: print i ## The location of the number in the Fibonacci set. print [j for j, x in enumerate(fibs) if x == i] </code></pre> <p>Every number I've tested for (including some <a href="http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibtable.html" rel="nofollow">large ones</a>) comes out with a match, but Project Euler isn't accepting the answer I'm getting.</p> <p>I read that the answer is the 4782th number, but I'm getting that the first number with over 1000 digits is the 4787th,</p> <pre><code>11867216745258291596767088485966669273798582100095758927648586619975930687764095025968215177396570693265703962438125699711941059562545194266075961811883693134762216371218311196004424123489176045121333888565534924242378605373120526670329845322631737678903926970677861161240351447136066048164999599442542656514905088616976279305745609791746515632977790194938965236778055329967326038544356209745856855159058933476416258769264398373862584107011986781891656652294354303384242672408623790331963965457196174228574314820977014549061641307451101774166736940218594168337251710513138183086237827524393177246011800953414994670315197696419455768988692973700193372678236023166645886460311356376355559165284374295661676047742503016358708348137445254264644759334748027290043966390891843744407845769620260120918661264249498568399416752809338209739872047617689422485537053988895817801983866648336679027270843804302586168051835624516823216354234081479331553304809262608491851078404280454207286577699580222132259241827433 </code></pre> <p>and Project Euler is saying every answer I've tried is wrong. (Obviously I didn't try 4782 yet, as that would be cheating.)</p> <p>I'm tantalizingly close, and clearly something is going wrong, but what?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload