Quick actions

cmd+k|ctrl+k

Navigation

Languages

lucas-numbers/lucas-06.p6

Snippet info

Language

Raku

Visibility

public

Author

zostay

Created

2016-08-29T16:31:31Z

Updated

2016-08-29T16:31:31Z

subset NonNegativeInt of Int where * >= 0;
sub lucas(NonNegativeInt $nth) returns NonNegativeInt {
    given $nth {
        when 0 { 2 }
        when 1 { 1 }
        default { lucas($nth - 1) + lucas($nth - 2) }
    }
}

say lucas(8);
INFO