Post History
Lua 5.4, 67 60 bytes function(x)return x==1 and 0 or 1+f(({x/2,3*x+1})[x%2+1])end Attempt This Online! Credits to @Moshi for more shortening.
Answer
#3: Post edited
- # [Lua 5.4](https://lua.org/versions.html#5.4), <s>67</s> 60 bytes
- ``` lua
- function(x)return x==1 and 0 or 1+f(({x/2,3*x+1})[x%2+1])end
- ```
[Attempt This Online!](https://ato.pxeger.com/run?1=m704pzRxwaI026WlJWm6Fjdt0krzkksy8_M0KjSLUktKi_IUKmxtDRUS81IUDBTyixQMtdM0NKor9I10jLUqtA1rNaMrVI20DWM1U_NSoGaopwHVZSrYKhjqKBgaKKTkc3EWFGXmlWhk6iikgQgDTU0uuPIFCyA0AA)- Credits to [@Moshi](https://codegolf.codidact.com/users/53196) for more shortening.
- # [Lua 5.4](https://lua.org/versions.html#5.4), <s>67</s> 60 bytes
- ``` lua
- function(x)return x==1 and 0 or 1+f(({x/2,3*x+1})[x%2+1])end
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m704pzRxwaI026WlJWm6Fjdt0krzkksy8_M0KjSLUktKi_IUKmxtDRUS81IUDBTyixQMtdM0NKor9I10jLUqtA1rNaMrVI20DWM1U_NSoGaopAHVZSrYKhjqKBgaKKTkc3EWFGXmlWhk6iikaWRqanLB1S5YAKEB)
- Credits to [@Moshi](https://codegolf.codidact.com/users/53196) for more shortening.
#2: Post edited
# [Lua 5.4](https://lua.org/versions.html#5.4), 67 bytes- ``` lua
function(x,_)return x==1 and _ or f(x%2==0 and x/2 or 3*x+1,_+1)end- ```
[Attempt This Online!](https://ato.pxeger.com/run?1=m704pzRxwaI026WlJWm6Fjed00rzkksy8_M0KnTiNYtSS0qL8hQqbG0NFRLzUhTiFfKLFNI0KlSNbG0NwCIV-kYgMWOtCm1DnXhtQ83UvBSoUeppQIlMBVsFQx0FQwOFlHwuzoKizLwSjUwdoBlAwkBTkwuufMECCA0A)
- # [Lua 5.4](https://lua.org/versions.html#5.4), <s>67</s> 60 bytes
- ``` lua
- function(x)return x==1 and 0 or 1+f(({x/2,3*x+1})[x%2+1])end
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m704pzRxwaI026WlJWm6Fjdt0krzkksy8_M0KjSLUktKi_IUKmxtDRUS81IUDBTyixQMtdM0NKor9I10jLUqtA1rNaMrVI20DWM1U_NSoGaopwHVZSrYKhjqKBgaKKTkc3EWFGXmlWhk6iikgQgDTU0uuPIFCyA0AA)
- Credits to [@Moshi](https://codegolf.codidact.com/users/53196) for more shortening.
#1: Initial revision
# [Lua 5.4](https://lua.org/versions.html#5.4), 67 bytes ``` lua function(x,_)return x==1 and _ or f(x%2==0 and x/2 or 3*x+1,_+1)end ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m704pzRxwaI026WlJWm6Fjed00rzkksy8_M0KnTiNYtSS0qL8hQqbG0NFRLzUhTiFfKLFNI0KlSNbG0NwCIV-kYgMWOtCm1DnXhtQ83UvBSoUeppQIlMBVsFQx0FQwOFlHwuzoKizLwSjUwdoBlAwkBTkwuufMECCA0A)