- /
-
efficient sieve, primes < 207,360,000
on 2 Dec 2023
- 5
- 26
- 0
- 0
- 140
drawframe(1);
Write your drawframe function below
function drawframe(f)
sf=300;
m=(sf*f)^2;
o=zeros(sf*f,sf*f);
o(1)=1;
a=2;
while a<m
if o(a)==1
a=a+1;
continue
end
o(a+a:a:m)=1; % magic, thanks to MATLAB's vectorized operations
a=a+1;
end
o=o';
o=imresize(o,[300 300],'box'); % final image (frame 48) is 14,400 x 14,400 pixles so much
% information is lost when scaling down to animation size requirement of
% 300 x 300
imshow(o)
end
Animation
![](/responsive_image/300/300/0/0/0/cache/matlabcentral/communitycontests/uploaded_files/19899/animation.gif?a=true)