Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pragma solidity ^0.4.2;
contract Fibonacci {
mapping (uint => uint) public numberstoredonblockchain;
function fibonacci(uint number) returns(uint result) {
if(numberstoredonblockchain[number] != 0) return numberstoredonblockchain[number];
if (number == 0) return 0;
else if (number == 1) return 1;
else {
numberstoredonblockchain[number] = Fibonacci.fibonacci(number - 1) + Fibonacci.fibonacci(number - 2);
return numberstoredonblockchain[number];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment