Please answer my question.
Attachments:
Answers
Answered by
2
Answer:
YOUR ANSWER IS IN THE ATTACHMENT.
Attachments:
Answered by
2
Answer: The required java program is :-
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
scan.close();
boolean flag = false;
for (int i = 2; i <= num/2; ++i) {
if (num % i == 0) {
flag = true;
break;
}
}
if (!flag) {
System.out.println(num+" is a prime number.");
}
else {
System.out.println(num+" is not a prime number.");
}
}
}
Please mark it as Brainliest.
Similar questions
Nevertheless, it's good answer!