Skip to main content
added 105 characters in body; edited title
Source Link

Output the jugglerJuggler sequence

The jugglerJuggler sequence is described as follows. Beginning with an input a1\$a_1\$, the next term is defined by the recurrence relation

$$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}$$

The sequence terminates when it reaches 1, as all subsequent terms would then be 1.

Task

Given an input n\$n\$ greater than or equal to 2, write a program/function/generator/etc. that outputs/returns the respective juggler sequence. The output can be in any reasonable form. You may not use a built-in that computes the juggler sequence, or any built-in that directly yields the result. You may assume that the sequence terminates in 1\$1\$.

Test Cases

Input: output
2: 2, 1
3: 3, 5, 11, 36, 6, 2, 1
4: 4, 2, 1
5: 5, 11, 36, 6, 2, 1

This is a code golf. Shortest code in bytes wins.

Output the juggler sequence

The juggler sequence is described as follows. Beginning with an input a1, the next term is defined by the recurrence relation

The sequence terminates when it reaches 1, as all subsequent terms would then be 1.

Task

Given an input n greater than or equal to 2, write a program/function/generator/etc. that outputs/returns the respective juggler sequence. The output can be in any reasonable form. You may not use a built-in that computes the juggler sequence, or any built-in that directly yields the result. You may assume that the sequence terminates in 1.

Test Cases

Input: output
2: 2, 1
3: 3, 5, 11, 36, 6, 2, 1
4: 4, 2, 1
5: 5, 11, 36, 6, 2, 1

This is a code golf. Shortest code in bytes wins.

Output the Juggler sequence

The Juggler sequence is described as follows. Beginning with an input \$a_1\$, the next term is defined by the recurrence relation

$$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}$$

The sequence terminates when it reaches 1, as all subsequent terms would then be 1.

Task

Given an input \$n\$ greater than or equal to 2, write a program/function/generator/etc. that outputs/returns the respective juggler sequence. The output can be in any reasonable form. You may not use a built-in that computes the juggler sequence, or any built-in that directly yields the result. You may assume that the sequence terminates in \$1\$.

Test Cases

Input: output
2: 2, 1
3: 3, 5, 11, 36, 6, 2, 1
4: 4, 2, 1
5: 5, 11, 36, 6, 2, 1

This is a code golf. Shortest code in bytes wins.

added 63 characters in body
Source Link
Seadrus
  • 1.4k
  • 11
  • 24

The juggler sequence is described as follows. Beginning with an input a1, the next term is defined by the recurrence relation

The sequence terminates when it reaches 1, as all subsequent terms would then be 1.

Task

Given an input n greater than or equal to 2, write a program/function/generator/etc. that outputs/returns the respective juggler sequence. The output can be in any reasonable form. You may not use a built-in that computes the juggler sequence, or any built-in that directly yields the result. You may assume that the sequence terminates in 1.

Test Cases

Input: output
2: 2, 1
3: 3, 5, 11, 36, 6, 2, 1
4: 4, 2, 1
5: 5, 11, 36, 6, 2, 1

This is a code golf. Shortest code in bytes wins.

The juggler sequence is described as follows. Beginning with an input a1, the next term is defined by the recurrence relation

The sequence terminates when it reaches 1, as all subsequent terms would then be 1.

Task

Given an input n greater than or equal to 2, write a program/function/etc. that outputs/returns the respective juggler sequence. The output can be in any reasonable form. You may not use a built-in that computes the juggler sequence, or any built-in that directly yields the result.

Test Cases

Input: output
2: 2, 1
3: 3, 5, 11, 36, 6, 2, 1
4: 4, 2, 1
5: 5, 11, 36, 6, 2, 1

This is a code golf. Shortest code in bytes wins.

The juggler sequence is described as follows. Beginning with an input a1, the next term is defined by the recurrence relation

The sequence terminates when it reaches 1, as all subsequent terms would then be 1.

Task

Given an input n greater than or equal to 2, write a program/function/generator/etc. that outputs/returns the respective juggler sequence. The output can be in any reasonable form. You may not use a built-in that computes the juggler sequence, or any built-in that directly yields the result. You may assume that the sequence terminates in 1.

Test Cases

Input: output
2: 2, 1
3: 3, 5, 11, 36, 6, 2, 1
4: 4, 2, 1
5: 5, 11, 36, 6, 2, 1

This is a code golf. Shortest code in bytes wins.

Tweeted twitter.com/StackCodeGolf/status/699141902461964288
Made some clarifications (roll back edit if it isn't what you had in mind)
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

The juggler sequencejuggler sequence is described as thus:follows. Beginning with an input a1, the next term is defined by the recurrence relation

The sequence terminates when it reaches 1, as all subsequent terms would then be 1.

Task

Given an input n greater than or equal to 22, write a program/function/etc. that outputs/returns the respective juggler sequence. The output can be in any reasonable form. You may not use a builtinbuilt-in that computes the juggler sequence, or any builtinbuilt-in that directly yields the result.

Test Cases

Test Cases

Input: output
2: 2, 1
3: 3, 5, 11, 36, 6, 2, 1
4: 4, 2, 1
5: 5, 11, 36, 6, 2, 1

This is a code golf. Shortest code in bytes wins.

The juggler sequence is described as thus:

Given an input n greater than or equal to 2, write a program/function/etc. that outputs/returns the respective juggler sequence. The output can be any reasonable form. You may not use a builtin that computes the juggler sequence, or any builtin that directly yields the result.

Test Cases

Input: output
2: 2, 1
3: 3, 5, 11, 36, 6, 2, 1
4: 4, 2, 1
5: 5, 11, 36, 6, 2, 1

This is a code golf. Shortest code in bytes wins.

The juggler sequence is described as follows. Beginning with an input a1, the next term is defined by the recurrence relation

The sequence terminates when it reaches 1, as all subsequent terms would then be 1.

Task

Given an input n greater than or equal to 2, write a program/function/etc. that outputs/returns the respective juggler sequence. The output can be in any reasonable form. You may not use a built-in that computes the juggler sequence, or any built-in that directly yields the result.

Test Cases

Input: output
2: 2, 1
3: 3, 5, 11, 36, 6, 2, 1
4: 4, 2, 1
5: 5, 11, 36, 6, 2, 1

This is a code golf. Shortest code in bytes wins.

Source Link
Seadrus
  • 1.4k
  • 11
  • 24
Loading