Problem 54119. Create the Ulam spiral
Have you ever seen this wonderful spiral ? The Ulam Spiral is arranging prime numbers in a clockwise spiral starting in 0.
Given an n by n matrix of 0s, fill it with 1 if the number is prime, in that order :
[7 8 9;
6 1 2;
5 4 3;]
Which will give you :
[1 0 0;
0 0 1;
1 0 1;]
As you experiment, look out for the strange patterns that emerge!
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers14
Suggested Problems
-
Remove all the words that end with "ain"
2170 Solvers
-
Back to basics 12 - Input Arguments
586 Solvers
-
302 Solvers
-
446 Solvers
-
Determine if Input is Oddish or Evenish (Odd/Even Sum of Digits)
273 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!