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

m
Line 300:
=={{header|Haskell}}==
<lang haskell>import Text.Printf (printf)
import Control.Monad (guard)
 
sequence_A069654 :: [(Int,Int)]
sequence_A069654 = go 1 $ (,) <*> length . divisorscountDivs <$> [1..]
where
divisorscountDivs n = foldr f 0 [1..floor (sqrt $ realToFrac n)] >>= \x -> do
where
guard (n `mod` x == 0)
f d r | n `mod` d == 0 = let y = n `div` xd in if d == y then succ r else r+2
if x == y then [x]| elseotherwise = [x,y]r
go t ((n,d):xs) | d == t = (t,n):go (succ t) xs
| otherwise = go t xs
 
main :: IO ()
Anonymous user