Here's the sequence version: import Data.Sequence as Seq josephus k n = reduce (fromList [1..n]) where reduce xs | Seq.null xs = [] | otherwise = case viewl (rotate (k-1) xs) of x :< xs' -> x : reduce xs' rotate i xs = back >< front where (front, back) = Seq.splitAt (i `mod` Seq.length xs) xs