Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: phi div by 0 error

by Athanasius (Monsignor)
on Sep 02, 2013 at 02:42 UTC ( #1051874=note: print w/ replies, xml ) Need Help??

in reply to phi div by 0 error

Simplify! :-)

#! perl use strict; use warnings; use bignum; my ($even, $odd) = (1, 1); for (1 .. 47) { $even += $odd; $odd += $even; print "phi = ", ($odd / $even), "\n"; }

47 iterations gives phi correct to 38 decimal places:

phi = 1.61803398874989484820458683436563811772

Update: Timed (with Time::HiRes) at less than 0.3 seconds.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Comment on Re: phi div by 0 error
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1051874]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-12-21 05:56 GMT
Find Nodes?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?

    Results (103 votes), past polls