type CircularArray = struct val mutable arr: int array val mutable position: int val mutable stepNum: int val increment: int new(i) = {arr=[|0|]; position=0; stepNum=1; increment=i} member this.step() = this.position <- 1 + (this.position + this.increment) % (Array.length this.arr) this.arr <- Array.insertAt this.position this.stepNum this.arr this.stepNum <- this.stepNum + 1 end let () = let mutable arr = new CircularArray(377) for i = 1 to 2017 do arr.step() arr.arr[arr.position+1] |> printfn "%d" let mutable p = 0 let mutable oneth = 1 for i = 1 to 50000000 do p <- (p + (377 % i) + 1) % i if p = 0 then oneth <- i printfn "%d" oneth