11.07.2015 Views

Lista 03a - DCC/UFMG

Lista 03a - DCC/UFMG

Lista 03a - DCC/UFMG

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

39) Escreva um algoritmo em PORTUGOL que calcule os N-menores números primos.Este número N deve ser lido do teclado.algoritmo L3P039;varinteiro: N, I, J, K;lógico: SIT;inícioleia(N);K ← 2; { número primo candidato }para I de 1 até N façaSIT ← verdadeiro;J ← 2 ;enquanto ( SIT e J < K ) façase (K mod J = 0 ) entãoSIT ← falso;fim-seJ ← J + 1;fim-enquantose ( SIT ) entãoimprima(I,"-ésimo número primo é: ",K);senãoI ← I + 1;fim-seK ← K + 1;fim-parafimprogram l3p039;varN, I, J, K: integer ;SIT: boolean;beginwrite('Digite um numero: ');read(N);K := 2; { numero primo candidato }I := 1;while (I

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!