so for my code i am trying to generate all the prime numbers between 2 and a given user input...i have succeeded in that. however, I also need to include all the excluded multiplies of that prime number.

EX:

2: 4 6 8 ....

3: 9 15 21....

this is what i have so far...

Scanner keyboard = new Scanner(System.in); int size; int [] numberArray; int [] out; System.out.println("Enter the size of the array from 1 to 100:"); size = keyboard.nextInt(); numberArray = new int[size]; //Fill the array. for (int i=1; i<size; i++) { numberArray[i]=i; } numberArray[1] = -1; //Identify 2 as the first prime number and then remove all numbers that are evenly divisible by 2 //start the for loop with 2 for (int i=2; i<size; i++){ //if the number has not already been discluded if(numberArray[i] != -1){ for(int j = 0; j < size; j++ ){ // if the number is a multiple of another number if(numberArray[j]%numberArray[i] == 0 && numberArray[j] != numberArray[i] ){ //disclude it numberArray[j] = -1; } } } } //print for(int i = 1; i < size; i ++){ if(numberArray[i] != -1) System.out.println(numberArray[i] + ":"); } System.out.println();

any help would be greatly appreciated!