```
numtrials = 10000;
empty = 0;
for i = 1:numtrials
    seat = zeros(1,100);
    seat(randi(100)) = 1;
     for p = 2:99   % second person in line will look for seat 2, only  up to 99 because I want to see if 99 is zero
         if seat(p) == 0
             seat(p) = 1;
         else
             while seat(randi(100)) == 0
             seat(randi(100)) = 1;
             end
         end
     end
     if seat(100) == 0
         empty = empty + 1;
     end
end
disp(empty)
 X = empty/numtrials;   
disp(['The probability that your seat will be available is ', num2str(X)])

```

100 people are standing in line, the person in the front sits at a random seat, everyone else sits in order. If a person finds their seat taken they sit at another random seat. I'm trying to find the probability that seat 100 will be open by the time the last person in line gets to it. My question is how can I make my while loop look for a seat that is open ( equal to 0) and assign it a one, The part in question is after the Else statement.