Fibonacci n-step number sequences: Difference between revisions
→{{header|Perl}}: eliminate hard-coded value
m (→{{header|PL/I}}: fixed a misspelling.) |
SqrtNegInf (talk | contribs) (→{{header|Perl}}: eliminate hard-coded value) |
||
Line 3,086:
<lang perl>use strict;
use warnings;
use feature
no warnings 'experimental';
use List::Util <max sum>;
sub fib_n ($n = 2, $xs = [1], $max = 100) {
my @xs = @$xs;
while (
push @xs, sum @xs[ max($len - $n, 0) .. $len-1 ];
}
Line 3,099 ⟶ 3,098:
}
say $_-1 . ': ' . join
say "\nLucas: " . join
{{out}}
<pre>1: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765
|