Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
isPrime
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.Scanner; class Rextester { private static boolean _isPrime(int... pack) { if(pack[1] < 2) return pack[0] < 2 ? false : true; return pack[0] % pack[1] == 0 ? false : Rextester._isPrime(pack[0], pack[1] - 1); } public static boolean isPrime(int n) { return Rextester._isPrime(n, n/2); } public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); boolean isP = Rextester.isPrime(n); System.out.print(isP); } }
run
|
edit
|
history
|
help
0
Java
Basic LinkedList in Java
ChangePI
Multiples of 3 and 5
2.C
Reverse Number in java
Hi
Kochergina_2
Simple imitation for show banners on priorities
темп