1 day ago
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();
}
}
}
}
Labels:
kuliah
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment