# Drawing a sequence of circles

For every natural number from 1 to 150, draw a circle centered on the x-axis in that number and with the diameter equal to the number of divisors of the number. I don't know what should I do.

• Welcome to Mathematica.SE. Are you sure you are posting on the right site? There is nothing in your question making it clear that it is concerned with Mathematica software. – m_goldberg Oct 9 '19 at 17:42
• What have you tried so far? – user6014 Oct 9 '19 at 17:46

Graphics[
{r = Length[Divisors@#]/2;
ColorData["Rainbow"][(r - 1)/7],
Circle[{#, 0}, r]} & /@
Range[150],
ImageSize -> 504]


You can get the radii using the built-in function DivisorSigma directly:

n = 150;
radii = DivisorSigma[0, Range @ n]/2;


Coloring the circles based on radius:

Graphics[MapThread[{Thick, ColorData[{"Rainbow", {0, Max@radii}}]@#2, Circle[{#, 0}, #2]} &,


Coloring the circles based on the horizontal coordinate of the center:

Graphics[ MapThread[{Thick, ColorData[{"Rainbow", {0, n}}]@#,  Circle[{#, 0}, #2]} &,