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

m
Line 303:
 
sequence_A069654 :: [(Int,Int)]
sequence_A069654 = go 1 nDivCount$ (,) <*> length . divisors <$> [1..]
where
nDivCount = (,) <*> length . divisors <$> [1..]
divisors n = [1..floor (sqrt $ realToFrac n)] >>= \x -> do
guard (n `mod` x == 0)
let y = n `div` x
if x == y then [x] else [x,y]
go t ((n,d):xs) | d == t = (t,n):go (succ t) xs
| d == t | otherwise = (t,n):go (succ t) xs
| otherwise = go t xs
 
main :: IO ()
Anonymous user