Java Example Programs – Prime Number Program In Java

Hey, Today we will learn how to check the number is prime or not. First of all we need to know what is a prime number ? The simplest answer is the number can divide by 1 and the number itself then it’s a prime number  , Example 1 and 7.  here divide means no reminder value. so for 7 we can divide this number with 1 and 7 only . other number also can divide but there will be reminder value. So let’s check the program.


here in the output you can see that 9 is not a prime number because 9 can divide by 3 with a reminder 0. So number 9 can divide by 1,3,9 So it’s not a prime number.

Thanks for reading this post. Stay tune with us to get more practices programs.

Happy Coding Happy Living…

Leave a Reply

Notify of