What is the required radius of the smaller circles around a larger circle so they touch? I am trying to determine how to calculate the required radius of the smaller circles so they touch each other around the larger circle. (red box) 
I would like to be able to adjust the number of smaller circles and the radius of the larger circle.
As an example:
$$\begin{align}
R&=1.5\\
n&=9\\
r&=\,?
\end{align}$$



If you draw $n$ lines from the origin touching the small circles and $n$ lines from the origin to the center of each small circle you basically divide the $2 \pi$ angle into $2n$ equal angles, say $\theta$. Hence $\theta={\pi}/{n}$. Now a triangle with vertices the origin, the center of one of the small circles and a tangent point of the same circle is a right triangle since the tangent is perpendicular to the radius at the point of contact. You then have
$$
\sin \theta=\frac{r}{R}
$$
Putting it all together 
$$
r=R \sin \frac{\pi}{n}
$$
