[Java]/*** story: it is said that the famous Jewish historian Joseph PHUs had the following story, 39 Jews and Joseph and his friends hid in a cave. * 39 Jews decided to die rather than be attacked by the enemy, so they decided to commit suicide. 41 people arranged in a circle, the number of reports starts from 1st. Each report reaches 3rd. * This person must commit suicide, and then report again from the next report until all people commit suicide. However, Joseph and his friends did not want to follow the game. Joseph asked * his friends to pretend to follow the game first. He arranged his friends and himself in 16th and 31st positions, so he escaped the game of death. * @ Param num Number of people * @ param per number of people to extract a * @ return Joseph Ring array */public class Joseph PHUs {public static int [] arrayofjoseph PHUs (int num, int per) {int [] nums = new int [num]; int count = 0; int pos = 0; for (int I = 1; I <= num; I ++) {while (true) {pos = pos % num; if (nums [pos] = 0) {count ++;} if (count = per) {count = 0; break;} pos ++;} nums [pos] = I;} return nums;} // implement public static void main (String [] args) {int manNum = 41; int per = 3; int aliveNum = 3; int [] man = Joseph. arrayofjoseph PHUs (manNum, per); System. out. println ("yoqinfu ring:" + Arrays. toString (man); System. out. println ("L indicates where three surviving persons are to be put:"); for (int I = 0; I <manNum; I ++) {if (man [I]> manNum-aliveNum) System. out. print ("L"); else System. out. print ("D"); if (I + 1) % 5 = 0) System. out. print ("");}}}