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

Content added Content deleted
Line 304: Line 304:
sequence_A069654 = go 1 $ (,) <*> countDivisors <$> [1..]
sequence_A069654 = go 1 $ (,) <*> countDivisors <$> [1..]
where
where
countDivisors n = foldr f 0 [1..floor (sqrt $ realToFrac n)]
countDivisors n = foldr f 0 [1..floor $ sqrt $ realToFrac n]
where
where
f x r | n `mod` x == 0 = if n `div` x == x then r+1 else r+2
f x r | n `mod` x == 0 = if n `div` x == x then r+1 else r+2