1a) Modify the program CoinTosses to toss a coin n times and print out after every 100 tosses the proportion of heads minus 1/2. Do these numbers appear to approach 0 as n increases?

CoinTosses1a <- function(n){
    coin <- c("heads","tails")
    toss <- sample(coin, size = n, replace = TRUE)
    count_heads <- length(which(toss == "heads"))
    x <- count_heads/n - 0.5
   
    return(x)
   
}
CoinTosses1a(200)
## [1] 0.02

1b) Modify the program again to print out, every 100 times, both of the following quantities: the proportion of heads minus 1/2, and the number of heads minus half the number of tosses. Do these numbers appear to approach 0 as n increases?

CoinTosses1b <- function(n){
    coin <- c("heads","tails")
    toss <- sample(coin, size = n, replace = TRUE)
    count_heads <- length(which(toss == "heads"))
    x <- count_heads/n - 0.5
   
    return(c(x, count_heads - n/2))
   
}
CoinTosses1b(600)
## [1]  -0.02166667 -13.00000000