I have a prime number method here which checks if the user input is a prime number, I've done some stuff to try to make it more efficient, but I am wondering if there is anything else that can be done, maybe even make the complexity class constant? Thanks. Below is my code. [CODE] public static boolean checkPrime (int n) { if (n!=2) { if (n%2==0) { return false; } } for (int i=3; i<=Math.sqrt(n);i+=2) { if (n%i==0)//if n divided by i has a remainder of 0, then not prime { return false; //number is not prime, return false for …

Member Avatar
+0 forum 0

The End.