I have the following task to solve: I have 100 doors in a row from 1-100. I send 10 persons into the row of doors one after another. The doors are initially opened. 
first person opens every 5-th door;; 5, 10, 15, 20...100
second person opens every 10-th door; 10, 20, 30 40, 100
third person opens every 15-th door; 15,30 45... 100
This pattern continues until the last person opens door nr: 50 and 100 (50-th doors).

which doors are closed after everyone have passed? It should output the specific number of doors, (example, 5,70,75,96,100).

I have solved the issue in Java with the my code displayed underneath. I am now trying to solve it in R, but I have problems with the for loops, I'm not getting the correct answer (I must use for loop statements). Anyone have some suggestions how to solve it?

```
enter code here

int personer = 10;
        boolean[] doorOpen = new boolean [100];
        int startPosition;

for(int start = 5; start < 51; start +=5) {

            for(int i = start-1; i < doorOpen.length;  i = i + start) {

                if ( doorOpen [i] == false ) {
                    doorOpen[i] = true;
                    //System.out.println("endret d¯r nr: " + (i+1) + "  --------  " +" D¯r lukket : " + doorOpen[i] );

                } else {
                    doorOpen[i] = false;
                    //System.out.println("endret d¯r nr: " + (i+1) + "  --------  " +" D¯r lukket : " + doorOpen[i] );
                }
            }
            System.out.println();

        } 
for (int i = 0; i < doorOpen.length; i++) {

             if(doorOpen[i] == true) {
                 System.out.print((i+1) + "  ");
             }
         }  

    } // main slutt

```

My R code starts as follow:

```
enter code here

door_game <- function(total_doors=100,passes=10) {
doors <- rep(FALSE,total_doors)

for ....

return (which(doors==true))

door_game()

```