- or download this
$a=sqrt 5;print+(((1+$a)/2)**$_-((1-$a)/2)**$_)/$a,$/for 0..73
# For comparison, here is the result of the golfing
# that Tilly and I participated in earlier:
$a=1;print$a-=$b+=$a*=-1,$/for 0..73
- or download this
Benchmark: timing 100000 iterations of Binet, Golf...
Binet: 1 wallclock secs ( 0.70 usr + 0.00 sys = 0.70 CPU) @ 142653.
+35/s (n=100000)
Golf: 5 wallclock secs ( 4.75 usr + 0.00 sys = 4.75 CPU) @ 21065.9
+4/s (n=100000)
- or download this
Recursive: 118 wallclock secs (116.37 usr + 0.00 sys = 116.37 CPU) @
+ 0.09/s (n=10)
- or download this
#!perl -w
use strict;
...
return ( ( ( 1 + $root5 ) / 2 ) ** $index
- ( ( 1 - $root5 ) / 2 ) ** $index ) / $root5;
}