Latihan 2

Run Settings
LanguageJava
Language Version
Run Command
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Masukkan bilangan? "); int number = sc.nextInt(); boolean isPrime = true; if (number <= 1) { isPrime = false; } else { for (int i = 2; i <= Math.sqrt(number); i++) { if (number % i == 0) { isPrime = false; break; } } } if (isPrime) { System.out.println(number + " adalah bilangan prima."); } else { System.out.println(number + " bukan bilangan prima."); } } }
Editor Settings
Theme
Key bindings
Full width
Lines