7 ms·
But does it converge using wrapping math for all usize values? There might be a cycle in theory.
by progbits 3y ago
But does it converge using wrapping math for all usize values?
There might be a cycle in theory.
- kevincox 3y agoThere can be a cycle but IIRC Rust inherits C/C++'s rule that infinite loops without side effects are undefined behaviour. So there are cycles (for example 0) but since there are no side effects and the only way to escape the loop is the `return true` the compiler only has to handle the `return true` path.
- progbits 3y agoOh sure that is fine, I just wonder if colatz is proven to converge for 32bit/64bit wrapping integer math.