Post History
A Juggler sequence is a sequence that begins with a positive integer $a_0$ and each subsequent term is calculated as: $$a_{k+1} = \begin{cases} \left \lfloor a_k ^ \frac 1 2 \right \rfloor, &...
#2: Post edited
Juggler sequences
- A [Juggler sequence](https://en.wikipedia.org/wiki/Juggler_sequence) is a sequence that begins with a positive integer \$a_0\$ and each subsequent term is calculated as:
- $$a_{k+1} = \begin{cases}
- \left \lfloor a_k ^ \frac 1 2 \right \rfloor, & \text{if } a_k \text{ is even}\\\\\
- \left \lfloor a_k ^ \frac 3 2 \right \rfloor, & \text{if } a_k \text{ is odd}
- \end{cases}$$
- Eventually, once \$a_k\$ equals \$1\$, the sequence ends, as all subsequent terms will be \$1\$. It has been conjectured, but not proven, that all Juggler sequences reach 1.
- Given a positive integer \$n \ge 2\$, output the Juggler sequence beginning with \$a_0 = n\$ and ending in \$1\$. You may assume it will always terminate. You should only output a single \$1\$, and the sequence should be in calculated order (\$a_0, a_1, a_2,\$ etc.)
This is code golf, so the shortest code in bytes wins- ---
- ## Test cases
- ```
- 2: 2, 1
- 3: 3, 5, 11, 36, 6, 2, 1
- 4: 4, 2, 1
- 5: 5, 11, 36, 6, 2, 1
- 6: 6, 2, 1
- 7: 7, 18, 4, 2, 1
- 8: 8, 2, 1
- 9: 9, 27, 140, 11, 36, 6, 2, 1
- 10: 10, 3, 5, 11, 36, 6, 2, 1
- ```
- A [Juggler sequence](https://en.wikipedia.org/wiki/Juggler_sequence) is a sequence that begins with a positive integer \$a_0\$ and each subsequent term is calculated as:
- $$a_{k+1} = \begin{cases}
- \left \lfloor a_k ^ \frac 1 2 \right \rfloor, & \text{if } a_k \text{ is even}\\\\\
- \left \lfloor a_k ^ \frac 3 2 \right \rfloor, & \text{if } a_k \text{ is odd}
- \end{cases}$$
- Eventually, once \$a_k\$ equals \$1\$, the sequence ends, as all subsequent terms will be \$1\$. It has been conjectured, but not proven, that all Juggler sequences reach 1.
- Given a positive integer \$n \ge 2\$, output the Juggler sequence beginning with \$a_0 = n\$ and ending in \$1\$. You may assume it will always terminate. You should only output a single \$1\$, and the sequence should be in calculated order (\$a_0, a_1, a_2,\$ etc.)
- This is <a class="badge is-tag">code-golf</a>, so the shortest code in bytes wins
- ---
- ## Test cases
- ```
- 2: 2, 1
- 3: 3, 5, 11, 36, 6, 2, 1
- 4: 4, 2, 1
- 5: 5, 11, 36, 6, 2, 1
- 6: 6, 2, 1
- 7: 7, 18, 4, 2, 1
- 8: 8, 2, 1
- 9: 9, 27, 140, 11, 36, 6, 2, 1
- 10: 10, 3, 5, 11, 36, 6, 2, 1
- ```
#1: Initial revision
Juggler sequences
A [Juggler sequence](https://en.wikipedia.org/wiki/Juggler_sequence) is a sequence that begins with a positive integer \$a_0\$ and each subsequent term is calculated as: $$a_{k+1} = \begin{cases} \left \lfloor a_k ^ \frac 1 2 \right \rfloor, & \text{if } a_k \text{ is even}\\\\\ \left \lfloor a_k ^ \frac 3 2 \right \rfloor, & \text{if } a_k \text{ is odd} \end{cases}$$ Eventually, once \$a_k\$ equals \$1\$, the sequence ends, as all subsequent terms will be \$1\$. It has been conjectured, but not proven, that all Juggler sequences reach 1. Given a positive integer \$n \ge 2\$, output the Juggler sequence beginning with \$a_0 = n\$ and ending in \$1\$. You may assume it will always terminate. You should only output a single \$1\$, and the sequence should be in calculated order (\$a_0, a_1, a_2,\$ etc.) This is code golf, so the shortest code in bytes wins --- ## Test cases ``` 2: 2, 1 3: 3, 5, 11, 36, 6, 2, 1 4: 4, 2, 1 5: 5, 11, 36, 6, 2, 1 6: 6, 2, 1 7: 7, 18, 4, 2, 1 8: 8, 2, 1 9: 9, 27, 140, 11, 36, 6, 2, 1 10: 10, 3, 5, 11, 36, 6, 2, 1 ```