Solution (source code)

= Solution

A loaded gun remains loaded after its visit with <probability> $1/2$. An unloaded gun is loaded and then not fired with <probability> $(3/4)(1/2)=3/8$. The visited gun's new loaded <probability> is therefore
$$
p'=\frac p2+\frac{3(1-p)}8=\frac38+\frac p8.
$$
Preservation requires $p'=p$, giving
$$
\boxed{p=\frac37.}
$$
This is <product stationarity under single-coordinate Markov updates>: the visited coordinate has the same <Bernoulli distribution> afterward, and its <independent> local random decisions do not affect the other coordinates. Thus the originally <independent> <indicator random variables> remain jointly <independent> after each scheduled visit, not merely equal in their marginal <probabilities>.

Let $X_j$ be the <indicator random variable> that gun $j$ is loaded. Then $N=\sum_{j=1}^mX_j$ has <binomial distribution> with parameters $m,3/7$. By <linearity of expectation> and <independence> of the <indicator random variables>,
$$
\boxed{\mathbb EN=\frac{3m}{7},\qquad
\operatorname{Var}N=\sum_{j=1}^m\operatorname{Var}X_j
=m\frac37\frac47=\frac{12m}{49}.}
$$