Calculates Fibonacci to the limit you specify.

Can calculate fib(500) in roughly half a second.

You'll need the Math::BigInt module. As far as I know it comes default, but if you don't have it, use cpan

"sudo cpan Math::BigInt"

```
#!/usr/bin/perl
use warnings; use strict;
use Math::BigInt;
my $n = 2; my $a;
my @nums = qw(0 1);
print "Calculate Fibonacci sequence to [number]: ";
my $max = <STDIN>;
while ($n < $max) {
$a = Math::BigInt->new($nums[$n-1] + $nums[$n-2]);
push(@nums, $a);
$n++;
printf("%s\n", $a);
}
```

Sign in to comment.

Are you sure you want to unfollow this person?

Are you sure you want to delete this?

Click "Unsubscribe" to stop receiving notices pertaining to this post.

Click "Subscribe" to resume notices pertaining to this post.