pocketlang/test/benchmark/fib/fib.pk

15 lines
196 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(30))
2021-05-07 17:41:19 +08:00
end
print('elapsed:', clock() - start, 's')
2021-05-07 17:41:19 +08:00