# I is the number of iterations # feel free to change I <- 100000 winner <- 1:I for(i in 1:I) { #stay in while loop until either 6 or 7 is rolled stay <- 1 while(stay) { dice = sum(sample(1:6,2,replace=T)) if(dice==6 | dice==7) { stay <- 0 winner[i] <- dice } } } print(table(winner))