I looked at many things online which detail how to draw the Ulam Spiral, and all of them use various bad-sounding algorithms. I recently drew the Ulam Spiral and it went very quickly and the algorithm I used was both straightforward and basic-sounding. So I will reproduce it below so that others won’t have to suffer through wrong tutorials in the future. There are two big insights to our algorithm. The first is that we can figure out how many prime numbers we’ll need to generate based on the size of the dots and the size of our canvas, and the second is that, while figuring out a number’s location in the cartesian plane from first principles is tricky, if you just trace the spiral and increment the count as you go along, then you can largely avoid that problem. 
The first insight allows us to just use the Sieve of Eratosthenes (and not the over-clever not-really-the-sieve lazy one, but the totally basic eager one). The second insight allows us to just increment the counter as we walk around the squiral. Code is here for the interested, and the PDF it produces is getting printed out on my 24-inch roll-fed printer. I was thinking that I should trace the squiral in light gray to reinforce the pattern, and if that turns out to be really cool, I will reprint it.









