有限寿命的斐波那契兔子

作者:L. Grondin

http://rosalind.info/problems/fibd/

示例输入

6 3

示例输出

4

源代码: fibd-grondilu.pl

use v6;

sub MAIN(Int $n = 6, Int $m = 3) {
    my @population = (1, 0 xx ($m-1)).flat;
    for 1 .. $n-1 -> \n {
        @population.unshift: [+] @population[1..*-1];  # reproduction
        @population.pop;                               # death
    }

    say [+] @population;
}