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