Just for fun, with a recursive definition of the Fibonacci function:
#!/usr/bin/perl use strict; use warnings; use Memoize; memoize 'fibo'; my $val = shift; printf "%.12f\n", fibo($val+1)/fibo($val); sub fibo { my $n = shift; return $n if ($n < 2); return fibo ($n-1) + fibo ($n-2); }
This gives the following result:
$ perl fibo3.pl 32 1.618033988750
In reply to Re: phi div by 0 error
by Laurent_R
in thread phi div by 0 error
by perlaintdead
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |