<p dir="ltr">Hi Michael,</p>
<p dir="ltr">I suppose this is where you got the code from?<br>
<a href="https://www.quora.com/What-is-the-most-efficient-algorithm-to-check-if-a-number-is-a-Fibonacci-Number">https://www.quora.com/What-is-the-most-efficient-algorithm-to-check-if-a-number-is-a-Fibonacci-Number</a></p>
<p dir="ltr">It's the sixth result of the Google search "haskell: get if a number is a fibonacci number"</p>
<div class="gmail_quote">On May 10, 2016 1:59 AM, "Michael Litchard" <<a href="mailto:michael@schmong.org">michael@schmong.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I have some code that checks to see if a number is a fibonacci number. It's not mine, I got it from somewhere and I need to credit it. I am pretty sure I got it from Stack Exchange but my search for it went nowhere. If this looks familiar to you, or you can tell me better ways to search, please let me know.<br><br>isFib :: Integer -> Bool<br>isFib n = n == a where (_, a, _) = unFib (1, 1) n<br><br>unFib :: (Integer, Integer) -> Integer -> (Integer,Integer,Integer)<br>unFib (a, b) n<br>  | n < a = (0, 0, 1)<br>  | n < e = (2*k, c, d)<br>  | otherwise = (2*k + 1, e, f)<br>      where<br>        (k, c, d) = unFib (fibPlus (a, b) (a, b)) n<br>        (e, f)    = fibPlus (a, b) (c, d)<br><br>fibPlus :: (Integer, Integer) -> (Integer, Integer) -> (Integer,Integer)<br>fibPlus (a, b) (c, d) = (bd - (b - a)*(d - c), a*c + bd)<br>  where bd = b*d<br></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div>