Solution (source code)

= Solution

By <Bayes' theorem>,
$$
\boxed{P(X\mid R)=\frac{P(R\mid X)P(X)}{P(R)}
=\frac{(20/50)(1/2)}{16/35}=\frac7{16}}.
$$
The denominator sums red outcomes from both possible jar choices, as calculated in (i).