Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,7 @@
sub fib_iter {
my $n = shift;
use bigint try => "GMP,Pari";
my ($v2,$v1) = (-1,1);
($v2,$v1) = ($v1,$v2+$v1) for 0..$n;
$v1;
}

View file

@ -0,0 +1,4 @@
sub fibRec {
my $n = shift;
$n < 2 ? $n : fibRec($n - 1) + fibRec($n - 2);
}

View file

@ -0,0 +1,24 @@
# Uses GMP method so very fast
use Math::AnyNum qw/fibonacci/;
say fibonacci(10000);
# Uses GMP method, so also very fast
use Math::GMP;
say Math::GMP::fibonacci(10000);
# Binary ladder, GMP if available, Pure Perl otherwise
use ntheory qw/lucasu/;
say lucasu(1, -1, 10000);
# All Perl
use Math::NumSeq::Fibonacci;
my $seq = Math::NumSeq::Fibonacci->new;
say $seq->ith(10000);
# All Perl
use Math::Big qw/fibonacci/;
say 0+fibonacci(10000); # Force scalar context
# Perl, gives floating point *approximation*
use Math::Fibonacci qw/term/;
say term(10000);