Find the sum of prime numbers within 500

N=500;
sum=0;
x=2:N;
for u=2:N
        n=find(rem(x,u)==0&x~=u);
        x(n)=[];
end  
for n=1:95
    sum=sum+x(n);
end
disp(sum)

Guess you like

Origin blog.csdn.net/Justinhhhh/article/details/81098811