Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

80%
+6 −0
Challenges Juggler sequences

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, &...

9 answers  ·  posted 3y ago by caird coinheringaahing‭  ·  last activity 3y ago by Shaggy‭

#2: Post edited by user avatar General Sebast1an‭ · 2021-08-12T14:50:58Z (over 3 years ago)
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 by user avatar caird coinheringaahing‭ · 2021-05-04T23:26:48Z (over 3 years ago)
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
```