How to check if my integer can be divided by 3 as below:
for(int i=0; i<24; i++){
//here, how to check if \"i\" can be divided by 3 completely(e.g. 3,
If you are using a loop, you can use the fact that every third number can be divided by 3.
for(int i = 0; i < 24; i += 3) {
System.out.println(i + " can be divided by 3");
System.out.println((i+1) + " cannot be divided by 3");
System.out.println((i+2) + " cannnot be divided by 3");
}
This avoids the need for a modulo and cuts the number of loops by a factor of 3.