You are viewing a single comment's thread. Return to all comments →
Hi, do you think this version will be faster? wanna hear your thought.
class Prime { void checkPrime(int... numbers) { for (int num : numbers) { if (isPrime(num)) { System.out.print(num + " "); } } System.out.println(); } boolean isPrime(int n) { if (n < 2) { return false; } for (int i = 2; i <= (int) Math.sqrt(n) && isPrime(i); i++) { if (n % i == 0) { return false; } } return true; } }
Prime Checker
You are viewing a single comment's thread. Return to all comments →
Hi, do you think this version will be faster? wanna hear your thought.