We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Can someone explain this weird behaviour around modulus in Haskell? I feel like I've got the 100th fibonacci number correctly, but can't get modulus to do what I want:
Prelude> mod 354224848179261915075 10000007
1759647
Prelude> 10^8+7
100000007
Prelude> mod 354224848179261915075 10^8+7
390632
Prelude> 354224848179261915075 mod 10^8+7
61915082
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci
You are viewing a single comment's thread. Return to all comments →
Can someone explain this weird behaviour around modulus in Haskell? I feel like I've got the 100th fibonacci number correctly, but can't get modulus to do what I want:
Prelude> mod 354224848179261915075 10000007 1759647 Prelude> 10^8+7 100000007 Prelude> mod 354224848179261915075 10^8+7 390632 Prelude> 354224848179261915075
mod
10^8+7 61915082