That unfortunately also doesn't seem to speed things up either.

On Mon, May 12, 2014 at 12:07 PM, Steven G. Johnson
<stevenj....@gmail.com>wrote:

> On Sunday, May 11, 2014 1:55:47 PM UTC-4, Stefan Karpinski wrote:
>>
>>         while nʹ > length(c) || c[nʹ] < 0
>>              nʹ = iseven(nʹ) ? nʹ>>1 : 3nʹ+1
>>             d += 1
>>         end
>>
>>
> As long as you are optimizing this, note that since 3n+1 is never odd you
> can speed things up by doing
>
> if iseven(n)
>      n = n >> 1
>      d += 1
> else
>      n = (3n + 1) >> 1
>      d += 2
> end
>
>
> You could save even more branches by doing a switch statement on the last
> few bits of n, once some future version of LLVM(?) allows us to emulate
> computed-goto functionality (
> https://github.com/JuliaLang/julia/issues/5410).
>

Reply via email to