File:Ulam4004001.png
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Size of this preview: 600 × 600 pixels. Other resolutions: 240 × 240 pixels | 480 × 480 pixels | 768 × 768 pixels | 1,024 × 1,024 pixels | 2,048 × 2,048 pixels | 4,001 × 4,001 pixels.
Original file (4,001 × 4,001 pixels, file size: 687 KB, MIME type: image/png)
File information
Structured data
Captions
Summary
[edit]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. |
Date | |
Source | Own work |
Author | Purpy Pupple |
Licensing
[edit]I, the copyright holder of this work, hereby publish it under the following licenses:
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
- You are free:
- 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
[edit]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
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 03:28, 3 February 2011 | 4,001 × 4,001 (687 KB) | Dllu (talk | contribs) | Resized back to the correct size (the original uploaded version was needlessly enlarged by 3x) | |
08:11, 24 December 2010 | 12,003 × 12,003 (1.15 MB) | Dllu (talk | contribs) | {{Information |Description={{en|1=An Ulam Spiral for numbers from 1 to 4004001.}} |Source={{own}} |Author=Purpy Pupple |Date=2010-12-23 |Permission= |other_versions= }} |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
File usage on other wikis
The following other wikis use this file:
- Usage on zh.wikipedia.org
Hidden categories: