This question already has an answer here:
- Show Ulam's spiral 5 answers
Get familiar with the Ulam spiral:
The aim is to print the spiral like in the picture above!
Write a function
where n is a odd positive integer and describes the size of the grid to print.
All non-primes numbers should be replaced with | horizontal and - vertical as in the picture above following the spiral. (Corner elements belongs to the vertical)
All numbers need to take the same amount of space visually and smaller numbers are right centered vertically:
10 needs two spaces on the left and
100 needs one space left.
This property depends on the biggest number you have to calculate.
- - 3 | | 7 - 2 | - -
The test for primes/sieve you have to write yourself.
Smallest byte code wins.
Bonus - 25 if you can make it more pretty find some symbols so that - and | takes the same space (-25 more if you can find a pretty corner symbol) and the symbol should show the line where the spiral evolves.