+ 5
[ASSIGNMENT] The Ulam Spiral
The Ulam Spiral The Ulam spiral or prime spiral is a graphical depiction of the set of prime numbers. It emphasizes the striking appearance in the spiral of prominent diagonal, horizontal, and vertical lines containing large numbers of primes. How to construct Ulam Spiral? [Mentioned in "best answer" below]
5 Answers
+ 4
The number spiral is constructed by writing the positive integers in a spiral arrangement on a square lattice, as shown.
(Img 1: https://cdncontribute.geeksforgeeks.org/wp-content/uploads/UlamSpiral-11-1.png)
The Ulam spiral is produced by specially marking the prime numbersâfor example by circling the primes or writing only the primes or by writing the prime numbers and non-prime numbers in different colorsâto obtain a figure like the one below.
(Img 2: https://cdncontribute.geeksforgeeks.org/wp-content/uploads/UlamSpiral-2-1.png)
Task:
For any sized   N x N  grid,  construct and show an Ulam spiral (counter-clockwise) of primes starting at some specified initial number  (the default would be 1),  with some suitably   dotty  (glyph) representation to indicate primes,  and the absence of dots to indicate non-primes.
You should demonstrate the generator by showing at Ulam prime spiral large enough to (almost) fill your terminal screen.
SOURCES: (Highly recommended to check out for more details...):
https://rosettacode.org/wiki/Ulam_spiral_(for_primes)
https://www.google.co.in/url?sa=t&source=web&rct=j&url=https://www.geeksforgeeks.org/the-ulam-spiral/&ved=2ahUKEwj20IbkvPDaAhWKM48KHcf3BJUQFjABegQIBxAB&usg=AOvVaw0ixYbHO5XusXjqKWyYip9U
https://www.alpertron.com.ar/ULAM.HTM
If value of N is made large enough, it would look kinda like this:
(Img 3: https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS9LwBeXgPkHuDWOmizb8M8RW6oIBzgSBEU508CvZH14pqhyl11aqt0RR2RAA )
*ANYONE WHO'S FOUND COPYING CODES FROM SITES WILL BE IMMEDIATELY DISQUALIFIED*
+ 3
Well, here it is:
https://code.sololearn.com/ca4pmn2ByLus/?ref=app
It is not perfect and some further improvements can be done, but it is good enough to be shown here as an example.
In fact it is not so different from my other code for just number spiral print out:
https://code.sololearn.com/czgGV6wZ4Ano/?ref=app
In only has one more additional check if the output number is Prime or not, and some other small improvements and corrections.
+ 3
UPDATE:
This is a version with the more or less the same output as required in the challenge description:
https://code.sololearn.com/cSK77kWD1S60/?ref=app
And FINALLY this is version with perfect output. If you find any bugs in spiral representation, feel free to contact me I will correct them:
https://code.sololearn.com/cd6nxyYicAs1/?ref=app
+ 2
Great effort Nevfy ! Maybe you could now try replacing the prime values displayed with a character symbol like '*,#,+,etc'.
Kinda like this: https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSXrtI0pmuNYzlSXaAw8uTmHYqvzR1mP6wHi9xLZdNvwgoNxcySRg
+ 1
@Rahul George With just console output it will not look as beautiful as on the image, but I think this result can be reached with WEB, but I'm not an expert in it. So, I authorize anyone to take my solution and make a web page based on it. :-)