Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class exercicio3 {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int[] k = new int[15], p = new int [15];
- int soma = 1, total = 0;
- Random rand = new Random();
- boolean ehPrimo = true;
- for (byte i = 0; i < 15; i++){
- k[i] = rand.nextInt(20);
- total = k[i] / 2;
- while (soma != total){
- if (k[i] % soma == 0 && (soma != k[i] || soma != 1)){
- ehPrimo = false;
- break;
- }
- soma++;
- }
- if (ehPrimo == true){
- p[i] = k[i];
- }
- ehPrimo = true;
- System.out.print(p[i] + ",");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment