Quick actions

cmd+k|ctrl+k

Navigation

Languages

Lucas Numbers (Custom Type)

Snippet info

Language

Raku

Visibility

public

Author

zostay

Created

2016-07-09T02:50:56Z

Updated

2016-07-09T02:50:56Z

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