4
$\begingroup$

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.

$\endgroup$
  • 2
    $\begingroup$ 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. $\endgroup$ – m_goldberg Oct 9 at 17:42
  • 1
    $\begingroup$ What have you tried so far? $\endgroup$ – user6014 Oct 9 at 17:46
11
$\begingroup$
Graphics[
 {r = Length[Divisors@#]/2;
    ColorData["Rainbow"][(r - 1)/7],
    Circle[{#, 0}, r]} & /@
  Range[150],
 ImageSize -> 504]

enter image description here

$\endgroup$
7
$\begingroup$

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]} &,
  {Range @ n, radii}]]

enter image description here

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

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

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.