pocketlang/test/benchmark/fib/fib.pk

16 lines
197 B
Plaintext
Raw Normal View History

2021-05-07 17:41:19 +08:00
2021-05-19 02:59:09 +08:00
from lang import clock
2021-05-07 17:41:19 +08:00
def fib(n)
if n < 2 then return n end
2021-05-07 17:41:19 +08:00
return fib(n - 1) + fib(n - 2)
end
start = clock()
2021-05-07 17:41:19 +08:00
for i in 0..10
print(fib(28))
end
2021-05-09 20:31:36 +08:00
print('elapsed:', clock() - start, 's')
2021-05-07 17:41:19 +08:00