Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub fib {
- my $a = 0;
- my $b = 1;
- sub {
- my $out = $a;
- my $c = $a + $b;
- $a = $b;
- $b = $c;
- $out;
- }
- }
- my $f = fib();
- my @arr = (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89);
- loop (my $i = 0; $i < @arr.elems; $i++) {
- $f() == @arr[$i] or die "Wrong value";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement