Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: phi div by 0 error

by Athanasius (Abbot)
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 wandering the Monastery: (18)
As of 2015-07-07 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (92 votes), past polls