# Fibonacci Benchmarks for fibonacci. Vyper is not included since it doesn't support cyclic function call :( ### Gas Cost | fib(n) | Zink | Solidity@0.8.21 | | ------ | ---- | --------------- | | 0 | 110 | 614 | | 1 | 110 | 614 | | 2 | 262 | 1322 | | 3 | 414 | 2030 | | 4 | 718 | 3446 | | 5 | 1174 | 5570 | ### Runtime Code | zink | solidity | | ---- | -------- | | 146 | 1052 | ## `zink` ```rust //! Zink fibonacci recursion #[no_mangle] pub extern "C" fn fib(n: usize) -> usize { if n < 2 { n } else { recursion(n - 1) + recursion(n - 2) } } ``` ``` 600035586010565b60005260206000f35b906000816002600190031015603d575b8160019003586010565b8101905081600290038092506001106020575b8181019150509060040156 ``` ## `solidity` ```sol /** * Solidity fibonacci recursion **/ function fib(uint n) public view returns (uint) { if (n < 2) { return n; } else { return fib(n - 1) + fib(n - 2); } } ``` ``` 608060405234801561001057600080fd5b506004361061002b5760003560e01c8063c6c2ea1714610030575b600080fd5b61004a600480360381019061004591906100ea565b610060565b6040516100579190610126565b60405180910390f35b60006002821015610073578190506100aa565b6100886002836100839190610170565b610060565b61009d6001846100989190610170565b610060565b6100a791906101a4565b90505b919050565b600080fd5b6000819050919050565b6100c7816100b4565b81146100d257600080fd5b50565b6000813590506100e4816100be565b92915050565b600060208284031215610100576100ff6100af565b5b600061010e848285016100d5565b91505092915050565b610120816100b4565b82525050565b600060208201905061013b6000830184610117565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061017b826100b4565b9150610186836100b4565b925082820390508181111561019e5761019d610141565b5b92915050565b60006101af826100b4565b91506101ba836100b4565b92508282019050808211156101d2576101d1610141565b5b9291505056fea2646970667358221220f28552ff642c48025f3617233333427ae50d06ce8b168d3e3e9c18f0cf9bc34d64736f6c63430008120033 ```