Thursday, November 21, 2013

Program in java to find prime number

Write a Program in java to find the prime number  instantly ?

What is JAVA?
Java is programming language that is useful to create a powerful java application
What is Prime Number?
Prime number is natural number which is greater than the 1 and no other divisors other than 1 or self.
Solutions
Class Prime number {
  Public static void main (String [] args) {
  Int num = 11;
  Int i;
  For (i=2; i < num; i++) {
  Int n = num%i;
  If (n==0) {
  System.out.println ("The number is not prime!");
  Break;
  }
  }
  If (i == num) {
  System.out.println ("The number is Prime number!");
  }
  }
}
Expertsmind.com offering the prime number program in this post for better understanding of prime number program in java.

No comments:

Post a Comment