This file is from Wikimedia Commons and may be used by other projects.
The description on its file description page there is shown below.
Summary
DescriptionUlam4004001.png
English: An Ulam Spiral for numbers from 1 to 16008001. Note that in this picture, the number 1 is coloured black even though it is, by convention, not prime. Also, note that the image is rotated by 90 degrees clockwise when compared with this picture.
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue
You may select the license of your choice.
Matlab Code
The image was generated with MATLAB in 1600 seconds. Here's my remarkably clunky and inefficient code:
function spiral
n=2000;
A=zeros(2*n+1);
B=A;
x=n+1;
y=x;
A(x,y)=true;
B(x,y)=true;
direction=1;
for i=2:(2*n+1)^2
switch direction
case 1
x=x+1;
B(x,y)=true;
A(x,y)=isprime(i);
if ~B(x,y+1)
direction=2;
end
case 2
y=y+1;
B(x,y)=true;
A(x,y)=isprime(i);
if ~B(x-1,y)
direction=3;
end
case 3
x=x-1;
B(x,y)=true;
A(x,y)=isprime(i);
if ~B(x,y-1)
direction=4;
end
case 4
y=y-1;
B(x,y)=true;
A(x,y)=isprime(i);
if ~B(x+1,y)
direction=1;
end
end
end
imwrite(imresize(~A,3,'nearest'),['output' num2str(n) '.png'],'png');
end
Captions
Add a one-line explanation of what this file represents