Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

snowbeard

By: a guest on Aug 13th, 2009  |  syntax: Haskell  |  size: 0.26 KB  |  views: 273  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data