Home » » prime number between range java

prime number between range java

Written By Basith on Sunday, February 24, 2013 | 10:49 PM




public class as1a{

public static void main(String[] args)
{

int i,j,r;
r=Integer.parseInt(args[0]);

for(i=2;i<=r;i++)
{
for(j=2;j<=i;j++)
{
if(i%j==0)
break;
}
if(i==j)
System.out.print(" " +i + " ");
}
}
}


/*Output:java as1a 25

2 3 5 7 11 13 17 19 23*/

0 comments:

Post a Comment

Followers