// Write a program to accept
// a number from command line
// arguments. Then decide
// the number is a prime or not
class prime
{
public static void main(String args[])
{
int a,i;
if(args.length==1)
{
a=Integer.parseInt(args[0]);
for(i=2 ; i<=a ; i++ )
if(a%i==0) break;
if(a==i)
System.out.println("Prime number");
else
System.out.println("Not Prime number");
}
else
System.out.println("java prime ##");
}
}
// a number from command line
// arguments. Then decide
// the number is a prime or not
class prime
{
public static void main(String args[])
{
int a,i;
if(args.length==1)
{
a=Integer.parseInt(args[0]);
for(i=2 ; i<=a ; i++ )
if(a%i==0) break;
if(a==i)
System.out.println("Prime number");
else
System.out.println("Not Prime number");
}
else
System.out.println("java prime ##");
}
}
No comments:
Post a Comment