How would you write a Java program to check if a number is prime?
You can use a `while` loop and check if the number is divisible by any other number except 1 and itself. If it is divisible, itâ€™s not prime.
You're on the right track, but using a `while` loop isn't necessarily the most efficient method.
How would you implement this with a `for` loop and avoid unnecessary checks?