import Data.Ratio import Numeric (floatToDigits) fracs :: [Rational] fracs = [ 17 % 91, 78 % 85, 19 % 51, 23 % 38, 29 % 33, 77 % 29, 95 % 23, 77 % 19, 1 % 17, 11 % 13, 13 % 11, 15 % 2, 1 % 7, 55 % 1] start :: Integer start = 2 isInt :: Float -> Bool isInt n = let (digs, p) = floatToDigits 10 n in length digs == p foo :: [Rational] -- fractions (ie, program) -> Integer -- seed integer (ie, pc) -> [Integer] foo fs s = let mfn = (\f -> let v = fromRational $ (s%1) * f in (isInt v, v)) in let bs = map mfn fs in let bb = dropWhile (\x -> fst x == False) bs in if null bb then [s] else let nxt = round $ snd $ head bb in s : foo fs nxt -- ghci> take 15 $ foo fracs 2 -- [2,15,825,725,1925,2275,425,25,1375,1625,1375,1625,1375,1625,1375] -- shoul've been -- [2,15,825,725,1925,2275,425,390,....