% How many rolls until we get a 6.
reps=1000
rec=NaN(1,reps); % where we'll keep the record
 
for k=1:reps
    
n=0;
gotit=false;
while not(gotit)
    n=n+1; % one more roll
    roll=ceil(6*rand);
    if roll==6
        gotit=true;
    end
end

rec(k)=n;

end

plot(sort(rec))
length(find(rec<=4))/reps          