Program to check whether a number is prime number or Not in java

Oct 7, 2019

In this program ,we check this number is prime number or not in java programming language..

import java.util.Scanner;
 class  Prime Number
 public static void main(String args[])
 int n;
 int count=0;  //division counter
 Scanner sc=new Scanner(;
 System.out.print("Enter a number");
 for(int i=1;i<=n;i++)
 count++;  //increment
 System.out.println(n+"is a Prime number");
 System.out.println(n+"is Not Prime number");
 (Run 1)
 Enter a number : 5
 5 is a prime number
 (Run 2)
 Enter a number : 8
 8 is not a Prime number

Leave a Reply

Your email address will not be published. Required fields are marked *