Skip to content

Instantly share code, notes, and snippets.

@dheshanm
Created September 24, 2015 13:01
Show Gist options
  • Select an option

  • Save dheshanm/fee9fab139ab479aefed to your computer and use it in GitHub Desktop.

Select an option

Save dheshanm/fee9fab139ab479aefed to your computer and use it in GitHub Desktop.
package starting.java.tutorials;
import java.util.Scanner;
/**
* Created by dheshan on 9/24/2015.
*/
public class PrimeCheck {
public static void main(String Args[]){
int number,i=0;
System.out.print("Enter the Number :");
Scanner in=new Scanner(System.in);
number=in.nextInt();
for(int n=2;n<number;n++){
if(number%n==0){
System.out.println("The number is not a Prime Number");
i=1;
break;
}
}
if(i==0){
System.out.println("The number is a Prime Number");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment