Babbage problem: Difference between revisions
Content deleted Content added
→Haskell Suffixes and integer roots: More intelligible output lines (by switching pairs from tuples to x:[y]) |
|||
Line 924:
<lang haskell>import Data.List (intercalate)
babbagePairs :: [
babbagePairs =
[0,1000000 ..] >>=
\x ->
let y = (x + 269696)
r = (sqrt . fromIntegral) y
i = floor r
in [
| r == fromIntegral i
]
main :: IO ()
main = do
let arrowed = intercalate " -> " . fmap show
mapM_ putStrLn (arrowed <$> take 10 babbagePairs)</lang>▼
▲ (take 10 babbagePairs)</lang>
{{Out}}
<pre>25264 -> 638269696
|