Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: phi div by 0 error

by Athanasius (Canon)
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 lurking in the Monastery: (3)
As of 2016-02-10 00:42 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (329 votes), past polls