Humble numbers: Difference between revisions
→{{header|Haskell}}: Redefined humbles in terms of Data.Set
(→{{header|Haskell}}: Redefined humbles in terms of Data.Set) |
|||
Line 658:
=={{header|Haskell}}==
<lang haskell>import Data.
import Control.Arrow ((&&&))
import Data.List (group)
import Data.Bool (bool)
----------------------HUMBLE NUMBERS-----------------------
humbles :: [Integer]
humbles =
humbles = filter (all (< 8) . primeFactors) [1 ..]▼
let go sofar = x : go (union pruned $ fromList ((x *) <$> [2, 3, 5, 7]))
where
(x, pruned) = deleteFindMin sofar
in go $ fromList [1]
▲-- humbles = filter (all (< 8) . primeFactors) [1 ..]
---------------------------TEST----------------------------
main :: IO ()
Line 675 ⟶ 678:
mapM_ (putStrLn . concat) $
chunksOf 10 $ (justifyRight 4 ' ' . show) <$> take 50 humbles
putStrLn "\nCount of humble numbers for each digit length 1-
mapM_ print $ take
digitCount :: Integer -> Int
Line 703 ⟶ 706:
81 84 90 96 98 100 105 108 112 120
Count of humble numbers for each digit length 1-
(1,9)
(2,36)
Line 709 ⟶ 712:
(4,197)
(5,356)
(6,579)
(7,882)
(8,1272)
(9,1767)
(10,2381)
(11,3113)
(12,3984)
(13,5002)
(14,6187)
(15,7545)
(16,9081)
(17,10815)
(18,12759)
(19,14927)
(20,17323)</pre>
=={{header|Julia}}==
|