SHARE
TWEET

snowbeard

a guest Aug 13th, 2009 338 Never
  1. josephus :: Int -> Int -> Int
  2. josephus n m = josephus_helper [0..(n-1)] m-1
  3.     where josephus_helper [a] m' = a
  4.           josephus_helper (a:as) m' | m' == 0 = josephus_helper as m-1
  5.                                     | otherwise = josephus_helper (as++[a]) m'-1
RAW Paste Data
Top