Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2014-07-30 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (234 votes), past polls