Prime Number Program in Java

A prime num­ber is a char­ac­ter­is­tic num­ber more than 1 that has no pos­i­tive divi­sors oth­er than 1 and itself. For instance 2, 3, 5, 7… are prime num­bers. Let’s see the prime num­ber pro­gram in java,

Program to check the prime numbers from 1 to 100 :

Out­put :

prime number program in java

Read Also :Palin­drome Pro­gram in Java

Prime Number Program in Java to check prime number from 1 to n :

Out­put : 

prime number program in java

Program to check given number is prime or not :

Out­put :

prime number program in java

Read Also : Dif­fer­ence between throw and throws in Java

Prime Number Program using Method in Java :