Here you will get program for prime number in java.

A number is prime if it is divisible by 1 or itself. For example 2, 3, 5, etc are prime numbers while 4, 6, 8, etc are not prime.

## Program for Prime Number in Java

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
class prime { public static void main(String...s) { int n,i; n=Integer.parseInt(s[0]); for(i=2;i<n;++i) { if(n%i==0) break; } if(i==n) System.out.println("\nNumber is prime"); else System.out.println("\nNumber is not prime"); } } |

**Output**