I am trying to check if on number is divisible by another, and currently I use this method:
int x = 70; int y = 30; if(x/y == Math.round(x/y)) { ... }
Is there a simpler way?
Advertisement
Answer
You can use modulus operator like this in your condition,
if (x%y == 0)