A Spiral of numbers

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
11
down vote

favorite
2












I am trying to produce a spiral of numbers from 1 through 101 with the following properties:



-- multiples of 5 are in a node shaped like pentagon



-- there is a special starburst node at numbers 3, 6, 11, 13, 17, 23, 29, 37, 43, 52, 56, 61, 63, 68, 69, 71, 72, 80, 91, 99.



(I think one could use the shapes.geometric library to achieve both of these if only I could figure out how to switch styles at specific values of x in the loop below.)



Here is where I am (with help from here):



documentclass[parskip]scrartcl
usepackage[margin=15mm]geometry
usepackagestix
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibrarycalc
usepackagepifont
usepackagewasysym
usepackagegraphicx

begindocument
hspace0pt vfill
begincenter
newcountercntRoot
begintikzpicture
coordinate (a) at (0,0);
coordinate (b) at (0:1);
foreach x in 1,...,100%
coordinate (c) at ($(b)!0.9cm!270:(a)$);
setcountercntRootx
addtocountercntRoot1
node[fill=white,draw,circle,inner sep=1pt] at (c)
$thecntRoot$;
coordinate (b) at (c);
;
endtikzpicture
endcenter
vfill
enddocument


I tried to implement ideas from this answer without much success. Any help would be much appreciated!










share|improve this question



























    up vote
    11
    down vote

    favorite
    2












    I am trying to produce a spiral of numbers from 1 through 101 with the following properties:



    -- multiples of 5 are in a node shaped like pentagon



    -- there is a special starburst node at numbers 3, 6, 11, 13, 17, 23, 29, 37, 43, 52, 56, 61, 63, 68, 69, 71, 72, 80, 91, 99.



    (I think one could use the shapes.geometric library to achieve both of these if only I could figure out how to switch styles at specific values of x in the loop below.)



    Here is where I am (with help from here):



    documentclass[parskip]scrartcl
    usepackage[margin=15mm]geometry
    usepackagestix
    usepackagetikz
    usetikzlibraryshapes.geometric
    usetikzlibrarycalc
    usepackagepifont
    usepackagewasysym
    usepackagegraphicx

    begindocument
    hspace0pt vfill
    begincenter
    newcountercntRoot
    begintikzpicture
    coordinate (a) at (0,0);
    coordinate (b) at (0:1);
    foreach x in 1,...,100%
    coordinate (c) at ($(b)!0.9cm!270:(a)$);
    setcountercntRootx
    addtocountercntRoot1
    node[fill=white,draw,circle,inner sep=1pt] at (c)
    $thecntRoot$;
    coordinate (b) at (c);
    ;
    endtikzpicture
    endcenter
    vfill
    enddocument


    I tried to implement ideas from this answer without much success. Any help would be much appreciated!










    share|improve this question

























      up vote
      11
      down vote

      favorite
      2









      up vote
      11
      down vote

      favorite
      2






      2





      I am trying to produce a spiral of numbers from 1 through 101 with the following properties:



      -- multiples of 5 are in a node shaped like pentagon



      -- there is a special starburst node at numbers 3, 6, 11, 13, 17, 23, 29, 37, 43, 52, 56, 61, 63, 68, 69, 71, 72, 80, 91, 99.



      (I think one could use the shapes.geometric library to achieve both of these if only I could figure out how to switch styles at specific values of x in the loop below.)



      Here is where I am (with help from here):



      documentclass[parskip]scrartcl
      usepackage[margin=15mm]geometry
      usepackagestix
      usepackagetikz
      usetikzlibraryshapes.geometric
      usetikzlibrarycalc
      usepackagepifont
      usepackagewasysym
      usepackagegraphicx

      begindocument
      hspace0pt vfill
      begincenter
      newcountercntRoot
      begintikzpicture
      coordinate (a) at (0,0);
      coordinate (b) at (0:1);
      foreach x in 1,...,100%
      coordinate (c) at ($(b)!0.9cm!270:(a)$);
      setcountercntRootx
      addtocountercntRoot1
      node[fill=white,draw,circle,inner sep=1pt] at (c)
      $thecntRoot$;
      coordinate (b) at (c);
      ;
      endtikzpicture
      endcenter
      vfill
      enddocument


      I tried to implement ideas from this answer without much success. Any help would be much appreciated!










      share|improve this question















      I am trying to produce a spiral of numbers from 1 through 101 with the following properties:



      -- multiples of 5 are in a node shaped like pentagon



      -- there is a special starburst node at numbers 3, 6, 11, 13, 17, 23, 29, 37, 43, 52, 56, 61, 63, 68, 69, 71, 72, 80, 91, 99.



      (I think one could use the shapes.geometric library to achieve both of these if only I could figure out how to switch styles at specific values of x in the loop below.)



      Here is where I am (with help from here):



      documentclass[parskip]scrartcl
      usepackage[margin=15mm]geometry
      usepackagestix
      usepackagetikz
      usetikzlibraryshapes.geometric
      usetikzlibrarycalc
      usepackagepifont
      usepackagewasysym
      usepackagegraphicx

      begindocument
      hspace0pt vfill
      begincenter
      newcountercntRoot
      begintikzpicture
      coordinate (a) at (0,0);
      coordinate (b) at (0:1);
      foreach x in 1,...,100%
      coordinate (c) at ($(b)!0.9cm!270:(a)$);
      setcountercntRootx
      addtocountercntRoot1
      node[fill=white,draw,circle,inner sep=1pt] at (c)
      $thecntRoot$;
      coordinate (b) at (c);
      ;
      endtikzpicture
      endcenter
      vfill
      enddocument


      I tried to implement ideas from this answer without much success. Any help would be much appreciated!







      tikz-pgf tikz-styles






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 3 at 4:19

























      asked Dec 3 at 4:14









      kan

      3,19312155




      3,19312155




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          21
          down vote



          accepted










          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) $x$;
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts % check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) $x$;
          globalnotfoundfalse% need global as inside a loop
          fi

          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) $x$;
          fi
          fi
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          usepackageexpl3
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts 3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          newcommandSetNode[1]
          int_compare:nTF int_mod:nn #1 5 = 0
          tikzsetmynode/.append~style=regular~polygon, regular~polygon~sides=5

          clist_if_in:NoTF l_starbursts #1
          tikzsetmynode/.append~style=starburst
          tikzsetmynode/.append~style=circle


          cs_generate_variant:Nn clist_if_in:NnTF noTF
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset... trickery. Anyway, here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          defsetnextstar#1,#2!%
          ifrelaxdetokenize#1relaxgdefnextstar200elsegdefnextstar#1gdefstarbursts#2fi%

          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]
          ifnum#1=nextstar
          tikzsetmynode/.append style=starburst
          expandaftersetnextstarstarbursts!
          else
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          tikzsetmynode/.append style=regular polygon, regular polygon sides=5
          else
          tikzsetmynode/.append style=circle
          fi
          fi

          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          The output is slightly different in that 80 now has a star.



          enter image description here






          share|improve this answer






















          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11










          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "85"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462906%2fa-spiral-of-numbers%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          21
          down vote



          accepted










          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) $x$;
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts % check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) $x$;
          globalnotfoundfalse% need global as inside a loop
          fi

          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) $x$;
          fi
          fi
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          usepackageexpl3
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts 3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          newcommandSetNode[1]
          int_compare:nTF int_mod:nn #1 5 = 0
          tikzsetmynode/.append~style=regular~polygon, regular~polygon~sides=5

          clist_if_in:NoTF l_starbursts #1
          tikzsetmynode/.append~style=starburst
          tikzsetmynode/.append~style=circle


          cs_generate_variant:Nn clist_if_in:NnTF noTF
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset... trickery. Anyway, here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          defsetnextstar#1,#2!%
          ifrelaxdetokenize#1relaxgdefnextstar200elsegdefnextstar#1gdefstarbursts#2fi%

          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]
          ifnum#1=nextstar
          tikzsetmynode/.append style=starburst
          expandaftersetnextstarstarbursts!
          else
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          tikzsetmynode/.append style=regular polygon, regular polygon sides=5
          else
          tikzsetmynode/.append style=circle
          fi
          fi

          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          The output is slightly different in that 80 now has a star.



          enter image description here






          share|improve this answer






















          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11














          up vote
          21
          down vote



          accepted










          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) $x$;
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts % check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) $x$;
          globalnotfoundfalse% need global as inside a loop
          fi

          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) $x$;
          fi
          fi
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          usepackageexpl3
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts 3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          newcommandSetNode[1]
          int_compare:nTF int_mod:nn #1 5 = 0
          tikzsetmynode/.append~style=regular~polygon, regular~polygon~sides=5

          clist_if_in:NoTF l_starbursts #1
          tikzsetmynode/.append~style=starburst
          tikzsetmynode/.append~style=circle


          cs_generate_variant:Nn clist_if_in:NnTF noTF
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset... trickery. Anyway, here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          defsetnextstar#1,#2!%
          ifrelaxdetokenize#1relaxgdefnextstar200elsegdefnextstar#1gdefstarbursts#2fi%

          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]
          ifnum#1=nextstar
          tikzsetmynode/.append style=starburst
          expandaftersetnextstarstarbursts!
          else
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          tikzsetmynode/.append style=regular polygon, regular polygon sides=5
          else
          tikzsetmynode/.append style=circle
          fi
          fi

          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          The output is slightly different in that 80 now has a star.



          enter image description here






          share|improve this answer






















          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11












          up vote
          21
          down vote



          accepted







          up vote
          21
          down vote



          accepted






          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) $x$;
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts % check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) $x$;
          globalnotfoundfalse% need global as inside a loop
          fi

          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) $x$;
          fi
          fi
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          usepackageexpl3
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts 3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          newcommandSetNode[1]
          int_compare:nTF int_mod:nn #1 5 = 0
          tikzsetmynode/.append~style=regular~polygon, regular~polygon~sides=5

          clist_if_in:NoTF l_starbursts #1
          tikzsetmynode/.append~style=starburst
          tikzsetmynode/.append~style=circle


          cs_generate_variant:Nn clist_if_in:NnTF noTF
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset... trickery. Anyway, here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          defsetnextstar#1,#2!%
          ifrelaxdetokenize#1relaxgdefnextstar200elsegdefnextstar#1gdefstarbursts#2fi%

          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]
          ifnum#1=nextstar
          tikzsetmynode/.append style=starburst
          expandaftersetnextstarstarbursts!
          else
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          tikzsetmynode/.append style=regular polygon, regular polygon sides=5
          else
          tikzsetmynode/.append style=circle
          fi
          fi

          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          The output is slightly different in that 80 now has a star.



          enter image description here






          share|improve this answer














          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) $x$;
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts % check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) $x$;
          globalnotfoundfalse% need global as inside a loop
          fi

          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) $x$;
          fi
          fi
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          usepackageexpl3
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts 3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          newcommandSetNode[1]
          int_compare:nTF int_mod:nn #1 5 = 0
          tikzsetmynode/.append~style=regular~polygon, regular~polygon~sides=5

          clist_if_in:NoTF l_starbursts #1
          tikzsetmynode/.append~style=starburst
          tikzsetmynode/.append~style=circle


          cs_generate_variant:Nn clist_if_in:NnTF noTF
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset... trickery. Anyway, here is the code:



          documentclass[parskip]scrartcl
          usepackage[margin=15mm]geometry
          usepackagestix
          usepackagetikz
          usetikzlibraryshapes,shapes.geometric,calc
          usepackagepifont
          usepackagewasysym
          usepackagegraphicx

          tikzset
          mynode/.style = fill=white,draw,inner sep=1pt

          newcommandstarbursts3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99
          defsetnextstar#1,#2!%
          ifrelaxdetokenize#1relaxgdefnextstar200elsegdefnextstar#1gdefstarbursts#2fi%

          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]
          ifnum#1=nextstar
          tikzsetmynode/.append style=starburst
          expandaftersetnextstarstarbursts!
          else
          pgfmathparseint(mod(x,5))
          ifnumpgfmathresult=0
          tikzsetmynode/.append style=regular polygon, regular polygon sides=5
          else
          tikzsetmynode/.append style=circle
          fi
          fi

          begindocument

          begintikzpicture
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in 1,...,100%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNodex
          node[mynode] at (c) $x$;
          coordinate (b) at (c);
          ;
          endtikzpicture

          enddocument


          The output is slightly different in that 80 now has a star.



          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 3 at 13:08

























          answered Dec 3 at 5:29









          Andrew

          30.3k34380




          30.3k34380











          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11
















          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11















          Thank you so much for your help! Much appreciated!
          – kan
          Dec 3 at 5:40




          Thank you so much for your help! Much appreciated!
          – kan
          Dec 3 at 5:40












          (Also, the comment "a star is born" had me giggling! We stan the talent!)
          – kan
          Dec 3 at 7:05




          (Also, the comment "a star is born" had me giggling! We stan the talent!)
          – kan
          Dec 3 at 7:05












          @kan Glad to be helpful and to amuse:)
          – Andrew
          Dec 3 at 9:56




          @kan Glad to be helpful and to amuse:)
          – Andrew
          Dec 3 at 9:56












          you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
          – jfbu
          Dec 3 at 10:53




          you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
          – jfbu
          Dec 3 at 10:53












          I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
          – sgmoye
          Dec 3 at 12:11




          I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
          – sgmoye
          Dec 3 at 12:11

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462906%2fa-spiral-of-numbers%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown






          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay