Post History
Wolfram Language (Mathematica), 38 bytes Tr[1^ResourceFunction["Collatz"]@#]-1& Don't Try it online! Doesn't work on TIO due to using the Collatz builtin which needs to be downloaded from ...
Answer
#3: Post edited
- # [Wolfram Language (Mathematica)], 38 bytes
```Tr[1^ResourceFunction["Collatz"]@#]-1&```- Don't [Try it online!][TIO-l2z7430a]
- Doesn't work on TIO due to using the Collatz builtin which needs to be downloaded from the [Function Repository](https://resources.wolframcloud.com/FunctionRepository/resources/Collatz)
- [Wolfram Language (Mathematica)]: https://www.wolfram.com/wolframscript/
- [TIO-l2z7430a]: https://tio.run/##y00syUjNTSzJTE78n2b7P6Qo2jAuKLU4v7QoOdWtNC@5JDM/L1rJOT8nJ7GkSinWQTlW11Dtf0BRZl5JdJq@Q1BiXnpqtKFBbOx/AA "Wolfram Language (Mathematica) – Try It Online"
- Relatively badly-golfed version without ResourceFunction (52 bytes):
`i=0;If[#!=1,i++;#0[If[EvenQ@#,Floor[#/2],3 #+1]],i]&`- [Try it online!](https://tio.run/##y00syUjNTSzJTE78/z@gKDOvJDrT1sDaMy1aWdHWUCdTW9ta2SAayHUtS80LdFDWccvJzy@KVtY3itUxVlDWNoyN1cmMVXMwj/3/HwA)
- Had to add a slightly janky print statement into the main body for the value of i to get reset on each evaluation.
- # [Wolfram Language (Mathematica)], 38 bytes
- Tr[1^ResourceFunction["Collatz"]@#]-1&
- Don't [Try it online!][TIO-l2z7430a]
- Doesn't work on TIO due to using the Collatz builtin which needs to be downloaded from the [Function Repository](https://resources.wolframcloud.com/FunctionRepository/resources/Collatz)
- [Wolfram Language (Mathematica)]: https://www.wolfram.com/wolframscript/
- [TIO-l2z7430a]: https://tio.run/##y00syUjNTSzJTE78n2b7P6Qo2jAuKLU4v7QoOdWtNC@5JDM/L1rJOT8nJ7GkSinWQTlW11Dtf0BRZl5JdJq@Q1BiXnpqtKFBbOx/AA "Wolfram Language (Mathematica) – Try It Online"
- Relatively badly-golfed version without ResourceFunction (52 bytes):
- i=0;If[#!=1,i++;#0[If[EvenQ@#,Floor[#/2],3 #+1]],i]&
- [Try it online!](https://tio.run/##y00syUjNTSzJTE78/z@gKDOvJDrT1sDaMy1aWdHWUCdTW9ta2SAayHUtS80LdFDWccvJzy@KVtY3itUxVlDWNoyN1cmMVXMwj/3/HwA)
- Had to add a slightly janky print statement into the main body for the value of i to get reset on each evaluation.
#2: Post edited
- # [Wolfram Language (Mathematica)], 38 bytes
`Tr[1^ResourceFunction["Collatz"]@#]-1&`- Don't [Try it online!][TIO-l2z7430a]
- Doesn't work on TIO due to using the Collatz builtin which needs to be downloaded from the [Function Repository](https://resources.wolframcloud.com/FunctionRepository/resources/Collatz)
- [Wolfram Language (Mathematica)]: https://www.wolfram.com/wolframscript/
- [TIO-l2z7430a]: https://tio.run/##y00syUjNTSzJTE78n2b7P6Qo2jAuKLU4v7QoOdWtNC@5JDM/L1rJOT8nJ7GkSinWQTlW11Dtf0BRZl5JdJq@Q1BiXnpqtKFBbOx/AA "Wolfram Language (Mathematica) – Try It Online"
- Relatively badly-golfed version without ResourceFunction (52 bytes):
- `i=0;If[#!=1,i++;#0[If[EvenQ@#,Floor[#/2],3 #+1]],i]&`
- [Try it online!](https://tio.run/##y00syUjNTSzJTE78/z@gKDOvJDrT1sDaMy1aWdHWUCdTW9ta2SAayHUtS80LdFDWccvJzy@KVtY3itUxVlDWNoyN1cmMVXMwj/3/HwA)
- Had to add a slightly janky print statement into the main body for the value of i to get reset on each evaluation.
- # [Wolfram Language (Mathematica)], 38 bytes
- ```Tr[1^ResourceFunction["Collatz"]@#]-1&```
- Don't [Try it online!][TIO-l2z7430a]
- Doesn't work on TIO due to using the Collatz builtin which needs to be downloaded from the [Function Repository](https://resources.wolframcloud.com/FunctionRepository/resources/Collatz)
- [Wolfram Language (Mathematica)]: https://www.wolfram.com/wolframscript/
- [TIO-l2z7430a]: https://tio.run/##y00syUjNTSzJTE78n2b7P6Qo2jAuKLU4v7QoOdWtNC@5JDM/L1rJOT8nJ7GkSinWQTlW11Dtf0BRZl5JdJq@Q1BiXnpqtKFBbOx/AA "Wolfram Language (Mathematica) – Try It Online"
- Relatively badly-golfed version without ResourceFunction (52 bytes):
- `i=0;If[#!=1,i++;#0[If[EvenQ@#,Floor[#/2],3 #+1]],i]&`
- [Try it online!](https://tio.run/##y00syUjNTSzJTE78/z@gKDOvJDrT1sDaMy1aWdHWUCdTW9ta2SAayHUtS80LdFDWccvJzy@KVtY3itUxVlDWNoyN1cmMVXMwj/3/HwA)
- Had to add a slightly janky print statement into the main body for the value of i to get reset on each evaluation.
#1: Initial revision
# [Wolfram Language (Mathematica)], 38 bytes `Tr[1^ResourceFunction["Collatz"]@#]-1&` Don't [Try it online!][TIO-l2z7430a] Doesn't work on TIO due to using the Collatz builtin which needs to be downloaded from the [Function Repository](https://resources.wolframcloud.com/FunctionRepository/resources/Collatz) [Wolfram Language (Mathematica)]: https://www.wolfram.com/wolframscript/ [TIO-l2z7430a]: https://tio.run/##y00syUjNTSzJTE78n2b7P6Qo2jAuKLU4v7QoOdWtNC@5JDM/L1rJOT8nJ7GkSinWQTlW11Dtf0BRZl5JdJq@Q1BiXnpqtKFBbOx/AA "Wolfram Language (Mathematica) – Try It Online" Relatively badly-golfed version without ResourceFunction (52 bytes): `i=0;If[#!=1,i++;#0[If[EvenQ@#,Floor[#/2],3 #+1]],i]&` [Try it online!](https://tio.run/##y00syUjNTSzJTE78/z@gKDOvJDrT1sDaMy1aWdHWUCdTW9ta2SAayHUtS80LdFDWccvJzy@KVtY3itUxVlDWNoyN1cmMVXMwj/3/HwA) Had to add a slightly janky print statement into the main body for the value of i to get reset on each evaluation.