class
Primeno
{
void
prime(int n)
{
int
d=2;
while(d<n)
{
if
(n%d==0)
break;
else
d++;
}
if(d==n)
System.out.println(n+"is
Prime");
}
public
static void main(String args[])
{
Primeno
p=new Primeno();
int
no=Integer.parseInt(args[0]);
int
i,j;
for(i=1;i<=no;i++)
{
p.prime(i);
}
}
}
Output:
D:\JavaPrograms\CmdPrograms>javac Primeno.java
D:\JavaPrograms\CmdPrograms>java Primeno 25
2is
Prime
3is
Prime
5is
Prime
7is
Prime
11is
Prime
13is
Prime
17is
Prime
19is
Prime
23is
Prime
0 Comments
Post a Comment