def J(n,k)n<2?1:(J(n-1,k)+k-1)%n+1end puts J(7, 1)puts J(7, 2)puts J(7, 3)puts J(7, 11)puts J(77, 8)puts J(123, 12)
Standard input is empty
7 7 4 1 1 21
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!