Last active
November 12, 2015 23:57
-
-
Save bwbaugh/41b523e3784421d6e25a to your computer and use it in GitHub Desktop.
Visualize the parity of the sum of digits from numbers of the Fibonacci sequence. https://oeis.org/A004090
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
import Data.Char (digitToInt) | |
import System.IO | |
main :: IO () | |
main = do | |
hSetBuffering stdout NoBuffering | |
putStrLn $ concatMap toFancy $ sumOfDigits fib | |
toFancy :: Integer -> String | |
toFancy x | |
| even x = "▓" | |
| otherwise = "░" | |
sumOfDigits :: [Integer] -> [Integer] | |
sumOfDigits = map (sum . map (toInteger . digitToInt) . show) | |
fib :: [Integer] | |
fib = 0 : 1 : zipWith (+) fib (tail fib) |
Author
bwbaugh
commented
Nov 12, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment