class Primetest { public static void main (String args[]) { int num, i; boolean prime = true; for (num = 3; num <= 50; num++) { prime = true; for (i = 2; i <= num / 2; i++) { if (num % i == 0) { prime = false; } } if (prime) System.out.println ("" num); } } }
No comments: