Smith is in jail and has 1 dollar; he can get out on bail if he has 8 dollars. A guard agrees to make a series of bets with him. If Smith bets A dollars, he wins A dollars with probability .4 and loses A dollars with probability .6. Find the probability that he wins 8 dollars before losing all of his money if

A. He bets 1 dollar each time (timid strategy).

# create a function to see if Smith can win
solve_p <- function(p){
  q <- 1-p
  n <- 1
  end_goal <- 8
  
  (1 - (q/p)^n) / (1 - (q/p)^end_goal)
  
}

# winning chance
p <- 0.4
win_prob <- solve_p(p)

win_prob
## [1] 0.02030135

B. he bets, each time, as much as possible but not more than necessary to bring his fortune up to 8 dollars (bold strategy).

win_3_time <- p * p * p

win_3_time
## [1] 0.064

C. Which strategy gives Smith the better chance of getting out of jail?

The best strategy for Smith to get out of jails is to place a larger bet since his chance of winning is higher than half.