• Remix
  • Share
  • New Entry

  • Josh

  • /
  • efficient sieve, primes < 207,360,000

on 2 Dec 2023
  • 5
  • 14
  • 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
Remix Tree