Math-Fibonacci

 view release on metacpan or  search on metacpan

lib/Math/Fibonacci.pm  view on Meta::CPAN

package Math::Fibonacci;
use strict;
use vars qw($VERSION @ISA @EXPORT_OK);
use POSIX qw(log10 ceil floor); 
require Exporter;
@ISA = qw(Exporter);
( $VERSION )  = '$Revision: 1.5 $' =~ /\s(\d+\.\d+)\s/; 

@EXPORT_OK = qw(term series decompose isfibonacci);

sub g ()     { "1.61803398874989" }  # golden ratio

sub term     { nearestint ((g ** shift) / sqrt(5)) } # nth term of the seq

sub series   { return map(term($_), 1..shift) } # n terms of the seq


sub decompose {                      # decomposes any integer into the sum of
                                     # members of the fibonacci sequence.
    my ($int) = @_;
    my $sum = decomp ($int);



( run in 1.659 second using v1.01-cache-2.11-cpan-524268b4103 )