public
Created

Programming Praxis, 15 June 2012

  • Download Gist
count_ones.hs
Haskell
1 2 3 4 5 6 7 8
import qualified Data.MemoCombinators as Memo
 
f = Memo.integral f'
where f' :: Int -> Int
f' 1 = 1
f' n = (length . filter (== '1') . show) n + f (n-1)
 
main = (print . head . filter (uncurry (==))) $ zip [2..] $ map f [2..]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.