I'm having trouble thinking of a solution to this problem that doesn't involve a loop. Basically, if something is greater than some arbitrary number, it loops around. Let's say 64 is the number.
0 => 0
32 => 32
64 => 64
96 => 32
128 => 64
160 => 32
192 => 64
Et cetera.
The way I'm currently doing it involves a while loop that checks to see if the value is over 64 and if it is, subtract 64 from it. Is there another way to do it that doesn't involve loops?
I'm using C# WinForms.
Mod the value by 64, it's an O(1) operation. Like this:
int number;
// number is initialized
number %= 64;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With