Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #sito Esa
- clc;
- n=input("Do jakiej liczby mam szukać?");
- tab=[];
- for i=1:1:n
- tab(i)=1;
- endfor
- tab(1)=0;
- i=2;
- while(i*i<n)
- for(j=2:1:n)
- tab(i*j)=0;
- end
- for(j=i+1:1:n)
- if(tab(j)==1)
- i=j;
- printf("%d\r\n",j);
- break;
- endif
- endfor
- end
- printf("Liczby pierwsze do %d to:", n);
- for(i=1:1:n)
- if(tab(i)==1) printf("%d, ", i); endif;
- endfor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement