Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
18
Task/Babbage-problem/Haskell/babbage-problem-2.hs
Normal file
18
Task/Babbage-problem/Haskell/babbage-problem-2.hs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import Data.List (intercalate)
|
||||
import Data.Maybe (maybe)
|
||||
import Safe (headMay)
|
||||
|
||||
maybeBabbage :: Integer -> Maybe Integer
|
||||
maybeBabbage upperLimit =
|
||||
headMay
|
||||
(filter ((269696 ==) . flip rem 1000000) ((^ 2) <$> [1 .. upperLimit]))
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
let upperLimit = 100000
|
||||
putStrLn $
|
||||
maybe
|
||||
(intercalate (show upperLimit) ["No such number found below ", " ..."])
|
||||
(intercalate " ^ 2 -> " .
|
||||
fmap show . (<*>) [floor . sqrt . fromInteger, id] . pure)
|
||||
(maybeBabbage upperLimit)
|
||||
Loading…
Add table
Add a link
Reference in a new issue