Anti-primes: Difference between revisions
Content deleted Content added
m OEIS link |
→{{header|Haskell}}: hlint, hindent. Specified imports, added type signatures. |
||
Line 549:
=={{header|Haskell}}==
<lang haskell>import Data.List (find, group)
import Data.Maybe (fromJust)
firstPrimeFactor
firstPrimeFactor n = head $ filter ((0 ==) . mod n) [2 .. n]
allPrimeFactors :: Int -> [Int]
allPrimeFactors 1 = []
allPrimeFactors n =
in first : allPrimeFactors (n `div` first)
factorCount :: Int -> Int
factorCount 1 = 1
factorCount n =
divisorCount
divisorCount = (,) <*> factorCount
hcnNext :: (Int, Int) -> (Int, Int)
hcnNext (num, factors) =
fromJust $ find ((> factors) . snd) (divisorCount <$> [num ..])
hcnSequence
hcnSequence = fst <$> iterate hcnNext (1, 1)
main :: IO ()
main =
{{output}}
<pre>
|