Last Updated: 17 July, 2022
On this tutorial page we are going to learn how to write a Java program to check whether the number is prime or not.
A prime is a natural number that is greater than 1 and divided by 1 or itself only. If any number is divisible by any other number, then that number is not a prime number.
Prime Numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23 ...
Let's see the Java program implementation.
Output
7 is a prime number.
16 is not a prime number.
25 is not a prime number.
29 is a prime number.
Output 1:
Enter the number: 11
11 is a prime number.
Output 2:
Enter the number: 15
15 is not a prime number.
That's all guys, hope this Java Program is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com