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 comments
Loading...
Problem Recent Solvers15
Suggested Problems
-
Find the sum of all the numbers of the input vector
54879 Solvers
-
Find common elements in matrix rows
2720 Solvers
-
Remove the polynomials that have positive real elements of their roots.
1743 Solvers
-
Project Euler: Problem 8, Find largest product in a large string of numbers
1326 Solvers
-
Find the largest value in the 3D matrix
1681 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!