I implemented the same in Haskell a while ago:  <a href="https:&#x2F;&#x2F;github.com&#x2F;xyzzyz&#x2F;FibBinet&#x2F;blob&#x2F;master&#x2F;FibBinet.hs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;xyzzyz&#x2F;FibBinet&#x2F;blob&#x2F;master&#x2F;FibBinet.hs</a><p>With yours, both make interesting comparison of how similar problem is solved in different languages.