Monday, 28 May 2012

Program in Java to check a given number is prime number


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("not Prime!");
  break;
  }
  }
  if(i == num){
  System.out.println("Prime number!");
  }
  }
}

1 comment:

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

    Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

    ReplyDelete