To find the sum of any number of integers entered as command line arguments.
1 minute read
To find the sum of any number of integers entered as command line arguments.
Program:
import java.util.Scanner;
public class PrimeNumber
{
public static void main(String[] args)
{
int i,n,count=1;
Scanner sc= new Scanner(System.in);
System.out.println("Enter a number");
n=sc.nextInt();
for(i=2;i<n;i++)
if((n%i)==0)
count=0;
if(count==1)
System.out.println(n+" is a prime number");
else
System.out.println(n+" is not a prime number");
}
}
OutPut:
Enter a number
4
4 is not a prime number
Post a Comment