Fibonacci
Pure computation, metered op by op.
- Language
- Lua
- Bytecode
- 184bytes
- Cards
- 21
- Units on the Weft VM
- 1 139 311CU
- Budget it opens with
- 1 300 000CU
- Runs
- Inline, in one transaction
-- Each call, add and compare is charged in compute units.
local function fib(n)
if n < 2 then return n end
return fib(n - 1) + fib(n - 2)
end
local out = {}
for i = 1, 12 do
out[i] = fib(i)
end
print("fib 12 =", out[12])
return out