3 ms·
what about: a = ((a & 0x01)? (a*3)+1 : a)>>1; anyway, when you think about it, you can skip everything between 0 and max_a0/2 because for any value there ther
by toolslive 13y ago
what about:
a = ((a & 0x01)? (a*3)+1 : a)>>1;
anyway, when you think about it, you can skip everything between 0 and max_a0/2 because for any value there there is one with a longer chain (its double). that's a factor 2 in all languages.
- mhath 13y agoOf course halving the range checked would also be an improvement. My own improvement was meant only to reduce the memory usage of antimora's code.