Sequence: smallest number greater than previous term with exactly n divisors: Difference between revisions

Line 301:
<lang haskell>import Data.List (nub)
import Text.Printf (printf)
import Control.Monad (guard)
 
sequence_A069654 :: [(Int,Int)]
Line 306 ⟶ 307:
where
nDivCount = (,) <*> divisorCount <$> [1..]
divisorCount = length . nub . foldr (\(a, b) r -> a:b:r) [] . divisors
where
divisors n = [1..ceiling (x,sqrt $ realToFrac n)] `div`>>= \x) ->
| x <- [1..ceilingguard (sqrtn $`mod` realToFracx n== 0) >> [x, n `div` x]
, n `mod` x == 0 ]
go t ((n,d):xs)
| d == t = (t,n):go (succ t) xs
Anonymous user