The angle between the centers of the small circles is $\frac{2\pi}{n}$(radians), so the angle from one of their centers to their point of tangency is half of that, $\frac{\pi}{n}$. Then
$$\sin\frac\pi n = \frac r x$$
But we don't know what $x$ is yet. We can get it from
$$x + r = R$$
and combine the two equations:
$$x = R - r = \frac{r}{\sin\frac\pi n}$$
$$R = r \left(1 + \frac{1}{\sin\frac\pi n} \right)$$
$$R \sin\frac\pi n = r \left(\sin\frac\pi n + 1 \right)$$
The angle between the centers of the small circles is $\frac{2\pi}{n}$(radians), so the angle from one of their centers to their point of tangency is half of that, $\frac{\pi}{n}$. Then
$$\sin\frac\pi n = \frac r x$$ But we don't know what $x$ is yet. We can get it from $$x + r = R$$ and combine the two equations: $$x = R - r = \frac{r}{\sin\frac\pi n}$$ $$R = r \left(1 + \frac{1}{\sin\frac\pi n} \right)$$ $$R \sin\frac\pi n = r \left(\sin\frac\pi n + 1 \right)$$