Fist java prime number check program in blog



import java.util.Scanner;

class maizn {

static boolean zo(int num) {

boolean re = true;

for (int i = 2; i < num / 2; ++i) {

if (num % i == 0) {

re = false;

break;


}


}

return re;

}

public static void main(String[] args) {

Scanner ko = new Scanner(System.in);

System.out.println("enter low number ");

int low = ko.nextInt();

System.out.println("enter the high nunber ");

int high = ko.nextInt();

int temp;

if (low > high) {

temp = low;

low = high;

high = temp;



}


while (high > low) {


if (zo(low)) {

System.out.println(low);



}

++low;

}

ko.close();

}


}

Comments