Powered by Blogger.

Print Prime Number Program in Java



Print Prime Number Program in Java

Prime number is only divisible by 1 and number it self. Whenever you write code in java for print prime number follow this concept.

Example of Print Prime Number Program in Java


class PrimeNumberExample
{
 public static void main(String args[])
{
  int i,m=0,flag=0;  
  int no=19;
  m=no/2;  
  for(i=2;i<=m;i++){  
   if(n%i==0){  
   System.out.println("Number is not prime");  
   flag=1;  
   break;  
   }  
  }  
  if(flag==0)  
  System.out.print(no);
  System.out.println(" is Prime Number");  
}
}  

Output

19 is Prime Number
Reference:




facebook
google-plus
twitter
pinterest

No comments :

Post a Comment

HTML Tutorial

images

About Sitesbay

This blog is related to Java Tutorial, C++ Tutorial, C Tutorial, Online Earning tips and more in very simple and easy way. Here i will try to give complete idea related to all new technology.

Java Tutorial

Java is Object oriented programming language, It is more secure and high performance language.

C++ Tutorial

C++ is also Object oriented programming language, It is more simple and easy to learn.

 
https://sitesbay.blogspot.com/?utm_medium=d2898efa59afcc0bc411921036e22b767ca37b09