Thursday, 7 June 2012

class PrimeSeries
{
public static void main(String args[])
{
 int k,m,j;
 for(j=2;j<100;j++)
 {
  k=0;
  for(int i=1;i<=j;i++) 
 {                                                  m=j%i;                                                if(m==0)                                                k=k+1;  
} 

if(k==2)
System.out.print("\t"+j);                      } 
}
}

D:\psr\Core java>javac PrimeSeries.java
D:\psr\Core java>java PrimeSeries

2       3       5       7       11      13      17      19      23      29      31      37      41      43      47      53      59      61      67            71      73      79      83      89      97

0 comments:

Post a Comment

Blogroll

Blogger templates

About