view paper/codes/fib.nqp @ 29:96e9cf9c2ea2

add source files
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 12 Feb 2019 17:02:56 +0900
parents
children
line wrap: on
line source

#! nqp

sub fib($n) {
    $n < 2 ?? $n !! fib($n-1) + fib($n - 2);
}

my $N := 29;

my $t0 := nqp::time_n();
my $z  := fib($N);
my $t1 := nqp::time_n();

say("fib($N) = " ~ fib($N));
say("time    = " ~ ($t1-$t0));