Anonymous user
Mian-Chowla sequence: Difference between revisions
→{{header|Haskell}}: third accumulator is just first element of second accumulator
(→{{header|Haskell}}: third accumulator is just first element of second accumulator) |
|||
Line 683:
mianChowlas :: Int -> [Int]
mianChowlas n =
let (_, cm
in reverse $ cm !! (n - 1)
nextMC :: (Set Int, [Int]
nextMC (sumSet, mcs
let valid x = all (not . flip member sumSet . (x +)) mcs
m = until valid succ n
in (foldr insert sumSet ((2 * m) : fmap (m +) mcs), m : mcs
main :: IO ()
|