Created
February 27, 2018 14:09
-
-
Save Doff3n/1c05cd03b9c8c26c0ce06a817ded14b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
https://remix.ethereum.org/#optimize=false&version=soljson-v0.4.20+commit.3155dd80.js