Tress, why have you posted this unrelated question here? It would make more sense to start a new thread!
Please bare that in mind in the future. Anyway, use this code:
public class prime {
public static void main(String[] args) {
int num;
int i;
int factor;
boolean isprime;
for(num = 2; num < 20; num++) {
isprime = true;
factor = 0;
// see if num is evenly divisible
for(i=2; i <= num/2; i++) {
if((num % i) == 0) {
// num is evenly divisible -- not prime
isprime = false;
factor = i;
}
}
if(isprime)
System.out.println(num + " is prime.");
else
System.out.println("Largest factor of " + num + " is " + factor);
}
}
}