pocketlang/test/benchmark/fib/fib.pk

16 lines
188 B
Plaintext
Raw Normal View History

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