Sequence: smallest number greater than previous term with exactly n divisors: Difference between revisions
Content added Content deleted
(added Haskell) |
|||
Line 301: | Line 301: | ||
<lang haskell>import Data.List (nub) |
<lang haskell>import Data.List (nub) |
||
import Text.Printf (printf) |
import Text.Printf (printf) |
||
divisorCount :: Int -> Int |
|||
⚫ | |||
⚫ | |||
⚫ | |||
sequence_A069654 :: [(Int,Int)] |
sequence_A069654 :: [(Int,Int)] |
||
Line 311: | Line 306: | ||
where |
where |
||
nDivCount = (,) <*> divisorCount <$> [1..] |
nDivCount = (,) <*> divisorCount <$> [1..] |
||
⚫ | |||
⚫ | |||
divisors n = [(x, n `div` x) |
|||
⚫ | |||
, n `mod` x == 0] |
|||
go t ((n,d):xs) |
go t ((n,d):xs) |
||
| d == t = (d,n) : go (succ t) xs |
| d == t = (d,n) : go (succ t) xs |
||
Line 334: | Line 334: | ||
a(15)= 4624 |
a(15)= 4624 |
||
</pre> |
</pre> |
||
=={{header|J}}== |
=={{header|J}}== |
||
<lang j> |
<lang j> |