I have a problem I need to do for school. The class is an advanced course in R at my high school. Like the title says, I need to figure out probability for a weighted coin flip. I need to land on heads 3 times or more out of 6, in 80% of all trials. I think the best way to attack the problem is to run a simulation of millions of trials, and then give an approximate answer based on the number of times in those trials that the coin landed on heads. My teacher was not able to explain the problem in a way I could understand, so I got advice from a friend to try using the coin.flip function and simply adjust the weights until I get the right percentage, like so:

```
total = 1
flip = 0
right = 0
for (total in 1:1000000000){
flip = coin.flip(coins = 6, flips = 10000000, weights = c(0.5, 0.5), getExact)
if ((sum(flip)) <= 3) {
right = right + 1
}
total = total + 1
}
right
```

...But, I think there must be an easier way. Can someone help me out?