Advertisement
obernardovieira

Números Primos

Apr 17th, 2013
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.44 KB | None | 0 0
  1. new n=10,c,i=3;
  2. for(new count;count<=n;) {
  3.     for(c=2;c<=i-1;c++) {
  4.         if ( i%c == 0 )
  5.             break;
  6.     }
  7.     if(c==i) {
  8.         printf("%d",i);
  9.         count++;
  10.     }
  11.     i++;
  12. }
  13. // o n é o numero maximo de numeros primos
  14.  
  15. new c,i=3,fim=50;
  16. while(i<fim) {
  17.     for(c=2;c<=i-1;c++) {
  18.         if ( i%c == 0 )
  19.             break;
  20.     }
  21.     if(c==i) {
  22.         printf("%d",i);
  23.     }
  24.     i++;
  25. }
  26. //o fim é até ao qual queremos saber os primos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement