public class TestCycle2{
public static void main(String[] args){
boolean cycle[] = new boolean[500];
for(int i=0;i<cycle.length;i++){
cycle[i]=true;
}
int count = cycle.length;
int j=1;
int index = 0;
while(count>1){
if(cycle[index]==true){
if(j==3){
cycle[index] = false;
count--;
j=0;
}
j++;
}
index++;
if(index==cycle.length){
index = 0 ;
}
}
System.out.println("index="+index);
for (index =0;index<cycle.length;index ++){
if(cycle[index]==true){
System.out.println("index="+index);
}
}
}
}