Numbers divisible by their individual digits, but not by the product of their digits.: Difference between revisions

m
→‎{{header|Haskell}}: Applied Hlint, Ormolu, pruned one import.
(Added Algol W)
m (→‎{{header|Haskell}}: Applied Hlint, Ormolu, pruned one import.)
Line 479:
 
=={{header|Haskell}}==
<lang haskell>import ControlData.MonadList.Split (chunksOf)
import Data.List.Split
import Text.Printf
 
divisible :: Int -> Bool
divisible = divdgt `ap`<*> dgt
where
where dgt = map (read . pure) . show
dgt = divdgt x d =map (notread $. elempure) 0. d)show
divdgt x d =
&& 0/=x `mod` product d
notElem && all ((0==).mod x) d
&& 0 /= x `mod` product d
&& all ((0 ==) . mod x) d
 
numbers :: [Int]
numbers = filter divisible [1 ..]
 
main :: IO ()
main = putStr $ unlines $ map (concatMap $ printf "%5d") $ split
where
where n = takeWhile (< 1000) numbers
split = chunksOf 10 n</lang>
 
{{out}}
9,659

edits