# Haskell, 67 bytes Here's the code: a&b|b<2=0|a==b=1+2&(b-1)|mod b a<1=1+2&(b-div b a)|1<2=(a+1)&b (2&) And here's one reason why Haskell is awesome: f = (2&) (-->) :: Eq a => a -> a -> Bool (-->) = (==) h=[f(5) --> 3 ,f(30) --> 6 ,f(31) --> 7 ,f(32) --> 5 ,f(100) --> 8 ,f(200) --> 9 ,f(2016^155) --> 2015 ] Yes, in Haskell you can define `-->` to be equivalent to `==`.