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

m
(Added Wren)
Line 330:
sequence_A069654 = go 1 $ (,) <*> countDivisors <$> [1..]
where
go t ((n,c):xs) | c == t = (t,n):go (succ t) xs
countDivisors n = foldr f 0 [1..floor $ sqrt $ realToFrac n]
| otherwise | otherwise = rgo t xs
where
countDivisors n = foldr f 0 [1..floor $ sqrt $ realToFrac n]
f x r | n `mod` x == 0 = if n `div` x == x then r+1 else r+2
where
| otherwise = r
go tf ((n,c):xs)x r | cn `mod` x == t0 = if n `div` x == (t,n):gox then (succr+1 t)else xsr+2
| otherwise | otherwise = go t xsr
 
main :: IO ()
Anonymous user