Sunday, 24 March 2013

A Java Program for Display 25 Prime Numbers.

class prime
{
public static void main(String args[])
{
int i,j,a=0,m=1;
for(i=1;i<=250;i++)
{ a=0;
for(j=2;j<=i-1;j++)
{
if(i%j==0)
{
a=1;
}
}
if(a!=1 && m<=25)
{
System.out.println(+i);
m=m+1;
}
}
}
}

No comments:

Post a Comment

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...