一道Java算法题,居然做了很久......

13年前
有100个人围成一个圈(编号0-99),从第0号的人开始从1报数,凡报到3的倍数的人离开圈子,然后再数下去,直到最后只剩一个人为止,问此人原来的位置是多少号?
public class Test  {      public static void main(String[] args)      {          // count人物总数,index人物编号,counter报数          int count = 100, index = 0, counter = 0;          // 剩余人数          int leavings = count;          // 圈          int[] circle = new int[count];          System.out.println("人物编号    报数");          while (true)          {              // 排的圈里的人物对应的值为-1表示出局              if (circle[index] != -1)              {                  circle[index] = index + 1;                  System.out.printf("%4d\t%3d\n", index, ++counter);              }                            if (counter % 3 == 0 && circle[index] != -1)              {                  if (leavings-- == 1)                  {                      System.out.printf("最后一个:\n%4d\t%3d\n", index, counter);                      break;                  }                  circle[index] = -1;              }                if (++index == count)              {                  System.out.println("剩余人数:" + leavings);                  index = 0;              }          }      }  }