import javax.swing.JOptionPane;
public class Prima {
public static void main (String [] args) {
String numString;
int numInt;
int jum = 0;
int i;
numString = JOptionPane.showInputDialog ("Masukkan angka : ");
numInt = Integer.parseInt (numString);
for (i=1; i<=numInt; i++) {
if (numInt % i ==0) {
jum = jum+1;
}
}
if (jum==2) {
JOptionPane.showMessageDialog (null, "Angka : " + numInt + "\nMerupakan bilangan prima");
} else {
JOptionPane.showMessageDialog (null, "Angka : " + numInt + "\nBukan merupakan bilangan prima");
}
}
}
0 comments:
Posting Komentar