- or download this
sub fib {
croak("…") if @_ != 1;
...
return $nth if $nth <= 1;
return fib( $nth - 1 ) + fib( $nth - 2 );
}
- or download this
my $fib_die_msg = 'fib() takes one positive integer as argument, abort
+ed';
sub fib {
...
return $nth if $nth <= 1;
return fib( $nth - 1 ) + fib( $nth - 2 );
}
- or download this
sub fib {
my($nth = shift) =~ m{^\d+$} and ! @_ or die $fib_die_msg;
...
}
- or download this
sub fib {
my $nth = shift;
...
return $nth if $nth <= 1;
return fib( $nth - 1 ) + fib( $nth - 2 );
}