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

Comments on Juggler sequences

Parent

Juggler sequences

+6
−0

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, & \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
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General comments (1 comment)
Post
+2
−0

Python 3, 64 bytes

def f(n):
 z=[n]
 while n>1:n=int(n**((n+.5)%2));z+=n,
 return z

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

General comments (2 comments)
General comments
caird coinheringaahing‭ wrote over 3 years ago · edited over 3 years ago
bastolski‭ wrote over 3 years ago

Hi! Is it me or your link is not working ?