Created
July 2, 2015 16:32
-
-
Save xnuk/3214b61382d3232adcbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sq2 :: Integer -> Integer -> [Integer] | |
sq2 left divider = let a = takeWhile (<= left) [(divider+i)*i | i<-[1..9]] | |
in if null a | |
then 0:sq2 (left*100) (divider*10) | |
else fromIntegral (length a):sq2 ((left - last a)*100) ((divider + fromIntegral (length a) * 2)*10) | |
main :: IO () | |
main = print (sqrt (2 :: Double)) >> mapM_ (putStr . show) (sq2 2 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment