let rec josephus n k = if n = 1 then 0 else (josephus (n - 1) k + k) mod n ;; josephus 50 3 + 1