CLICK HERE FOR FREE BLOGGER TEMPLATES, LINK BUTTONS AND MORE! »
Daisypath Wedding tickers

Sunday, October 25, 2009

Java : Program Bilangan Prima





{
public static void main(String[] args)
{
int a = 20;
boolean p = false;
System.out.println("Deret Bilangan Prima antar 2-20");
for (int i = 2; i <=a; i++) { if (i >= 2)
{
p = true;
for (int j = 2; j < i; j++)
{
if (i % j == 0)
{

p = false;
break;
}
}
}

if(p)
{

System.out.print(i);
System.out.println();

}
}

}
}

No comments:

Post a Comment