nonZeroMod method
The modulo n
of this int, returning n
when the modulo would give 0.
Example:
9.nonZeroMod(3) == 3
7.nonZeroMod(7) == 7
0.nonZeroMod(5) == 5
Implementation
int nonZeroMod(int n) {
final mod = this % n;
return mod == 0 ? n : mod;
}