Calculate Conditional Probability for program that does not crash I got these 2 questions in exam, but unfortunately i failed to solved these. 

1) you want to buy a computer. The probability that you can run the
  probabilistic program $X$ on it is $97$% provided that the computer's
  hardware is ok. If however the hardware is buggy then the program $X$
  crashes with a $50$% chance. The probability that the hardware is ok is
  $60$%.
a) Calculate the probability that $X$ does not crash. (I got answer : 0.782) 
b) Now you observe
  that the program $X$ runs perfectly fine. Calculate the probability that
  the hardware is ok. (I got answer : 0.744)
2) Your program uses a loop. It will repeat the loop until the user
  types the key. The user chooses a random key from the center of a
  keyboard, namely one out of $47$, each time she is asked. What is the
  expected no. of executions on the loop.

I will be very much thankful to you if someone help me explain this.
Thank you.
 A: 1. Let $X$ be an event that the probabilistic program does not crash, $H$ be an event that the hardware is ok.
From the question it is given that
$P(X|H) = \frac{97}{100}$, $P(H) = \frac{3}{5}$ and $P(X|H^{c}) = \frac{1}{2}$, where $H^{c}$ is the compement of $H$, that is an event that the hardware is buggy. 
a) We would like to find $P(X)$ and for that we will use the law of total probability,
$$P(X) = P(X|H)P(H) + P(X|H^{c})P(H^{c}) = \frac{391}{500} = 0.782 $$
b) Here we would like to find $P(H|X)$ and thus we proceed by using the Bayes Theorem
$$P(H|X) = \frac{P(X|H)P(H)}{P(X)} = \frac{291}{391}\approx 0.744. $$
2.
If I understand this problem well. Then we have a program which will be terminated if the user types a special key otherwise will repeat a loop. There are $47$ keys, the user picks one at random. The probability of success (that is stopping the program) is $p=\frac{1}{47}$. Clearly, we deal here with a geometric distribution with success probability $p$ and so the expected no. of executions of the loop is $\frac{1}{p}=47$.
