Quick actions

cmd+k|ctrl+k

Navigation

Languages

Rat Fib

Snippet info

Language

Perl

Visibility

public

Author

abradley10

Created

2023-03-13T21:47:57.934908Z

Updated

2023-03-13T21:47:57.934908Z

use bigrat;

my $ARGS = <STDIN>;
my ($counter, $seed1, $seed2) = split(/ /, $ARGS);

print "$counter repetitions: $seed1 $seed2 ";

my $next_to_last = Math::BigRat->new($seed1);
my $last = Math::BigRat->new($seed2);

for(1..$counter) {
  my $new = $last+$next_to_last;
  print "$new ";
  $next_to_last = $last;
  $last = $new;
}
INFO