public class Main {public static void main (string[] args) {//50 persons, starting from the first person, counting to 3 of the people are Countthree (50, 0, 3);} /** * Joseph Ring: Known n individuals (denoted by numbers 1,2,3...N respectively) sit around a round table. * From the number of people numbered K began to count, the number to m of the person out of the man, and his next person from 1 began to count, * the number to M of the person again, according to this rule repeat until the round table all the people out. * * @param n Total number of people * @param start sequence number starting off, start < n * @param m dequeue mark (can be greater than n) */private static void Countthree (int n, in t start, int m) {list<integer> list = new arraylist<integer> ();//Initialize list for (int i = 1; I <= n; i++) {List.ad D (i);} while (List.size () > 0) {//will be previously connected to the end of the list for (int j = 0; J < M-1; J + +) {List.add (List.remove (start));} Print the ordinal System.out.println (List.remove (start)) of the Dequeue;}}
Java implementation Joseph Ring: 50 people in a circle count, a number of 3 of the people quit, begging for the last remaining number of people