What's the chance for the closest whole number to $\frac{A}{B}$ is even? Both $A$ and $B$ are a random number from the $\left [ 0;1 \right ]$ interval.
I don't know how to calculate it, so i've made an estimation with excel and 1 million test, and i've got $0.214633$. But i would need the exact number.
 A: You can use the fact that the distribution of the ratio of two independent uniform $[0,1]$'s is $$ f_Z(z) = \left\{\begin{array}{ll}1/2& 0 < z < 1 \\\frac{1}{2z^2} & z >1  \end{array}\right.$$
Then you can calculate the probability that the closest integer is $i$: $$\int_{i-1/2}^{i+1/2} p_Z(z)dz. $$
For $i\ge2,$ we get $$ \int_{i-1/2}^{i+1/2} \frac{1}{2z^2}dz = \frac{1}{2i-1}-\frac{1}{2i+1}.$$
The probability that $0$ is the closest integer is $$ \int_0^{1/2}p_Z(z)dz = 1/4.$$
So the total probability that even numbers are closest is $$ 1/4 + \sum_{j = 1}^\infty \frac{1}{4j-1} - \frac{1}{4j+1} = 1/4 + 1-\pi/4.$$
The numerical answer you gave is close to $1-\pi/4$ so I guess you weren't counting zero amongst the even integers.
A: This is Problem 1993-B3 from the 54th Putnam exam.
The solution becomes obvious if we look at a graph of $(B,A)$ in the Cartesian unit square $[0,1]^2$.  Then the value $A/B$ is the slope of the line segment joining $(B,A)$ to the origin.  Define $[x]$ to indicate the nearest whole number to $x$.  Then clearly, when $A < B$, we must have $[A/B] = 0$, which occurs for points in the triangle with vertices $\{(0,0), (1,0), (1,1/2)\}$.  This triangle has area $1/4$.
For points with $A > B$, we have an infinite series of triangles with variable base along the edge joining $(0,1)$ and $(1,1)$, and common height $1$.  For a point $(x,1)$ along this edge, the rounded slope is $[1/x]$, and we require this to be an even integer; i.e., $$2k - 1/2 < 1/x < 2k + 1/2, \quad k \in \mathbb Z^+$$ or equivalently $$\frac{2}{4k+1} < x < \frac{2}{4k-1}.$$  Consequently the total area of these triangles is simply $$\frac{1}{2} \sum_{k=1}^\infty \frac{2}{4k-1} - \frac{2}{4k+1} = \sum_{m=1}^\infty \frac{(-1)^{m+1}}{2m+1} = 1 - \frac{\pi}{4}.$$  Adding in the value for the case $[A/B] = 0$, we get $$\frac{5-\pi}{4} \approx 0.46460183660255169038.$$  Your answer corresponds to the case where $[A/B]$ is a positive even integer.

