g | x | w | all
Bytes Lang Time Link
041AWK250911T184822Zxrs
027TIBASIC TI84 Plus CE Python250911T160302Zmadeforl
020YASEPL250908T141255Zmadeforl
007Vyxal 3241015T163056Zpacman25
028Casio BASIC Casio FX9750gIII241015T151416Zmadeforl
3433Perl 5160719T203037Zmsh210
035Juby241010T013901ZJordan
016Uiua241009T202102Znyxbird
7515Nibbles230901T145336ZDominic
6875Vyxal230901T131029Zlyxal
049Lua230831T001822Zbluswimm
030Raku230830T131320ZSean
010Vyxal220705T034322ZnaffetS
052Factor220527T130828Zchunes
007Jelly210503T183642Zcaird co
00905AB1E201009T113151ZKevin Cr
012Husk201009T095309ZRazetime
061C160717T162545Zuser5634
2221dc160718T032505Zjuh
077F#160719T205727Zasibahi
144Retina160718T215457Zmbomb007
062C#160717T173618Zaloisdg
010Jelly160215T034733ZDennis
030TIBasic160216T013237Zuser1812
041Python 3160215T040535ZCameron
122C++160215T230458ZMegaTom
012MATL160215T034844ZDavid
076JavaScript ES6160215T202131ZConor O&
018CJam160215T134828ZLuis Men
051R160215T052104Zmnel
039Mathematica160215T035347Znjpipeor
128Oracle SQL 11.2160215T073629ZJeto
016APL160215T042223ZAlex A.
070Haskell160215T061728ZMichael
012Pyth160215T035122Zizzyg
089TSQL160215T052937ZLiesel
030Julia160215T035638ZAlex A.
025Minkolang 0.15160215T044009ZEl'e
033JavaScript ES7160215T040053Zuser8165
071Java 7160215T034918ZGeobits
043TI BASIC160215T035505ZConor O&
102JavaScript ES6160215T033058ZConor O&

AWK, 41 bytes

{for(;$1-1;$1=int($1^($1%2+.5)))print$1}1

Attempt This Online!

Longer variant that's more interesting:

{for(;$(i++)-1;)$(i+1)=int($i^($i%2+.5))}1,$i=X

TI-BASIC (TI-84 Plus CE Python), 27 bytes

Input A
While log(A
Disp A
int(√(A)A^remainder(A,2→A
End
1

YASEPL, 20 bytes

=a'<`1=e$a%+.5!^e(<[

explanation:

=a'<`1=e$a%+.5!^e(<[   packed
=a'                    get user input (a)
   <                   print a
    `1        !    [   while a != 1...
      =e$a%                e = a % 2
           +.5               + .5
              !^e(         a = floor(a ^ e)
                  <        print again

translation of my casio basic answer :3

Vyxal 3, 7 bytes

ᶨЧḃ¿⁻√⌊

Vyxal It Online!

ᶨЧḃ¿⁻√⌊­⁡​‎‎⁡⁠⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁤​‎⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁡‏‏​⁡⁠⁡‌­
 Ч       # ‎⁡quadruple "element" lambda (we like arity grouping)
  ḃ      # ‎⁢parity
   ¿⁻    # ‎⁣if odd, cube
     √⌊  # ‎⁤square root and floor
ᶨ        # ‎⁢⁡loop and collect while unique
💎

Created with the help of Luminespire.

Casio BASIC (Casio FX-9750gIII), 28 bytes

?→A
A◢
While Ans≠1
Int Ans^(.5+MOD(Ans,2◢
WhileEnd

you have to press EXE to reveal each number, it will show 1 twice.

Perl 5, 34 33 bytes

33, plus 1 for -pE instead of -e

say;($_=int$_**($_%2+.5))-1&&redo

Explanation

First, -p sets the variable $_ equal to the input from stdin. Then we start a block of code:

  1. say prints $_.
  2. $_=int$_**($_%2+.5) sets $_ equal to the integer part of {$_ to the power of {{$_ modulo 2} + 0.5}}, due to the magic of order of operations (operator precedence). This assignment returns the new value of $_, and
  3. (...)-1&&redo tests that returned value, minus 1. If the difference is 0, do nothing; otherwise, redo this block.

Finally, -p prints $_.

Of equal length

Also uses -p.

say()-($_=int$_**($_%2+.5))&&redo

This: prints $_; assigns as above; tests whether the return value of say (which is 1), minus the new value of $_, is 0, and redoes the block if so; then prints $_ at the end.

But wait, we can save one more byte, so it's just 33…

Thanks to Xcali for pointing out that [in either of those scripts] 0| works instead of int.

J-uby, 35 bytes

:!~&(:**%[-:p,~:%&2|:+&0.5]|:floor)

Attempt This Online!

Uiua, 16 bytes

⍥(⌊√⨬∘ⁿ₃⊸◿2&p.)∞

Try it! (pure version)

⍥(⌊√⨬∘ⁿ₃⊸◿2&p.)∞
⍥(            )∞  # repeat until fixed point:
            &p.    #   print value
     ⨬  ⊸◿2       #   switch by mod 2:
      ∘            #     0: do nothing
       ⁿ₃          #     1: cube
   ⌊√              #   get floored sqrt

Nibbles, 7.5 bytes (15 nibbles)

`.$^^$^3%$~-2

Attempt This Online!

`.              # iterate while unique
  $             # starting with input:
        %$~     #  result-so-far modulo-2
      ^3        #  3 to the power of that (so: 3 or 1)
    ^$          #  result-so-far to the power of that
   ^       -2   #  floor square-root

Vyxal, 55 bitsv2, 6.875 bytes

∷.+e⌊)↔

Try it Online!

Explained

∷.+e⌊)↔­⁡​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌­
     )↔  # ‎⁡Generate until fixed point, starting with the input:
∷.+      # ‎⁢  Add the bit parity of the argument to 0.5 (0.5 if even, 1.5 if odd)
   e     # ‎⁣  And raise the argument to that number
    ⌊    # ‎⁤  Floor it.
💎

Created with the help of Luminespire.

Lua, 49 bytes

b=...repeat a=b print(a)b=b^(.5+b%2)//1until a==b

Try it online!

Raku, 30 bytes

{$_,{floor $_**(.5+$_%2)}...1}

Try it online!

This anonymous function returns the sequence of Juggler numbers. { floor $_ ** (.5 + $_ % 2) } evaluates each successive term of the sequence, the floor of the previous number $_ raised to a power which is one-half plus the that number modulo 2.

Vyxal, 10 bytes

λ∷d›½e⌊;İJ

Try it Online!

Factor, 52 bytes

[ [ 3 dupn . odd? 3/2 .5 ? ^ 1 /i dup 1 > ] loop . ]

Try it online!

Jelly, 7 bytes

*Ḃ×½ḞµƬ

Try it online!

Basically Dennis' method, but updated to use the modern version of Jelly. I initially had 9 bytes, but switching to the ×½ method saved 2 bytes.

How it works

*Ḃ×½ḞµƬ - Main link. Takes n on the left
     µ  - Group the previous links into a monad f(n):
 Ḃ      -   Bit; n % 2
*       -   n ** (n % 2)
   ½    -   n ** (1 / 2)
  ×     -   n ** (n % 2 + 1 / 2)
    Ḟ   -   Floor
      Ƭ - Repeatedly apply f(n), yielding [n, f(n), f(f(n)), ..., 1]

05AB1E, 12 9 bytes

Δ=DÉ·>;mï

-3 bytes thanks to @ovs.

Outputs each result on a separate line.

Try it online or verify some more test cases.

Explanation:

Δ          # Loop until the result no longer changes:
 =         #  Print the current value with trailing newline (without popping)
           #  (which will be the implicit input-integer in the first iteration)
  D        #  Duplicate the value
   É       #  Pop the copy, and check if it's odd (1 if odd; 0 if even)
    ·      #  Double that
     >     #  Increase it by 1
      ;    #  Halve it
       m   #  Take the current value to the power this 1/2 or 3/2
        ï  #  And then cast it to an integer to floor it

Husk, 14 12 bytes

U¡o⌊?^1.5√%2

Try it online!

Explanation

U¡ȯ⌊?^1.5√%2
 ¡             iterate over the input infinitely, creating a list
  ȯ            with the following three functions:
               take the previous result
          %2   modulo 2
    ?^1.5      if truthy, raise to 3/2th power
         √     else take square root
   ⌊           floor the result
U              cut the list at fixed point

C, 64 63 61 bytes

t;q(n){for(;!t;n=pow(n,.5+n%2))printf("%d%c ",n,n^1?44:t++);}

dc, 22 21 bytes

[pd2%2*1+^vd1<F]dsFxn

Explained:

[                # Begin macro definition
 p               # Peek at top of stack (print without popping, followed by newline)
 d               # Duplicate top of stack
 2%              # Mod 2: If even, 0; if odd, 1
 2*1+            # If even: 0*2+1==1; if odd: 1*2+1==3
 ^v              # Raise, then square root: equivalent to `^(0.5)' or `^(1.5)'
 d1<F            # If result is not 1, run macro again
]dsFx            # Duplicate macro, store as `F', execute
n                # Print the final "1"

There's a bug: When the input is 1, the output consists of two 1s.

F# 77 bytes

Doesn't terminate at 1, but keeps going.

let j=Seq.unfold(fun x->Some(x,floor(match x%2. with 0.->x**0.5|1.->x**1.5)))

Usage:

j 3.;;
> val it : seq<float> = seq [3.0; 5.0; 11.0; 36.0; ...]

Version that actually terminates at 1, 100 bytes

let j=Seq.unfold(fun x->if x=1. then None else Some(x,floor(match x%2. with 0.->x**0.5|1.->x**1.5)))

Ungolfed

let juggle input =
    let next x = 
        floor
            (match x % 2. with 
                | 0. -> x ** 0.5
                | 1. -> x ** 1.5
                | _ -> failwith "this should never happen") // addressing a compiler warning
    Seq.unfold (fun x -> if x = 1. then None else Some(x, next x)) input

Retina, 144 bytes

Input and output are in unary.

The 2nd-to-last line contains a space, and the two middle lines and the last line are empty.

{`(\b|)11+$
$&¶$&
m-1=`^(?=^(11)*(1?)).*$
$&,$2
(1+),1$
$1;,
1(?=1*;)
$%_
1+;
$%_
;|,

m-1=`^
1:
+`(1+):(11\1)
1 $2:
1+:$|:1+

-1=`(1+\b)
$#1
 

Try it online

Explanation

{`(\b|)11+$                 # Loop, Duplicate last line
$&¶$&
m-1=`^(?=^(11)*(1?)).*$     # Append ,n%2 to that line (number modulo 2)
$&,$2
(1+),1$                     # Cube that number if odd
$1;,
1(?=1*;)
$%_
1+;
$%_
;|,                         # (Last stage of cubing number)

m-1=`^                      # Integer square root of that number, 
1:                          #   borrowed and modified from another user's answer
+`(1+):(11\1)
1 $2:
1+:$|:1+

-1=`(1+\b)
$#1
 

Integer square root in Retina, by Digital Trauma

C#, 62 bytes

string f(int n)=>n+(n<2?"":","+f((int)Math.Pow(n,.5+n%2)));

Inspired by @user81655 and @Alex A., I used recursion.

Jelly, 12 11 10 bytes

*BṪ×½Ḟµ’п

Thanks to @Sp3000 for golfing off 1 byte!

Try it online!

How it works

*BṪ×½Ḟµ’п    Main link. Input: n

*B            Elevate n to all of its digits in base 2.
  Ṫ           Extract the last power.
              This yields n ** (n % 2).
   ×½         Multiply with sqrt(n). This yields n ** (n % 2 + 0.5).
     Ḟ        Floor.

      µ       Push the previous chain on the stack and begin a new, monadic chain.
        п    Repeat the previous chain while...
       ’        n - 1 is non-zero.
              Collect all intermediate results in an array.

TI-Basic, 30 Bytes

Prompt A
Repeat A=1
Disp A
int(A^(remainder(A,2)+.5->A
End
1

Python 3, 57, 45, 43, 41 bytes

Better Solution with suggestion from @mathmandan

def a(n):print(n);n<2or a(n**(.5+n%2)//1)

This method will print each number on a new line

Previous Solution: Cut down to 43 bytes after xnor's recommendation

a=lambda n:[n][:n<2]or[n]+a(n**(n%2+.5)//1)

You can call the above by doing a(10) which returns [10, 3.0, 5.0, 11.0, 36.0, 6.0, 2.0, 1.0]

The above will output the values as floats. If you want them as integers, then we can just add an extra 2 bytes for 43 bytes:

def a(n):print(n);n<2or a(int(n**(.5+n%2)))

C++, 122 bytes

#include <iostream>
void f(int n){int i;while(n^1){std::cout<<n<<',';for(i=n*n;i*i>(n%2?n*n*n:n);i--);n=i;}std::cout<<1;}

MATL, 13 12 bytes

`tt2\.5+^ktq

Try it online!

Explanation

`     % do...while loop
tt   % duplicate top of stack twice, takes implicit input on first iteration
2\    % take a_k mod 2
.5+^  % adds 0.5, to give 1.5 if odd, 0.5 if even, and takes a_k^(0.5 or 1.5)
kt    % Rounds down, and duplicates
q     % Decrement by 1 and use for termination condition---if it is 0, loop will finish

Thanks Luis for saving a byte!

JavaScript ES6, 76 bytes

Is a generator named j. To use, set a = j(<your value>);. To see the next value in the sequence, enter a.next().value.

function*j(N){for(yield N;N-1;)yield N=(N%2?Math.pow(N,3/2):Math.sqrt(N))|0}

Ungolfed:

function* juggler(N){
    yield N;
    while(N!=1){
        N = Math.floor(N % 2 ? Math.pow(N,3/2) : Math.sqrt(N));
        yield N;
    }
}

CJam, 18 bytes

ri{__2%.5+#i_(}g]p

Test it here

Similar to David's MATL answer.

R, 54 51 bytes

z=n=scan();while(n>1){n=n^(.5+n%%2)%/%1;z=c(z,n)};z

Saved 3 bytes thanks to plannapus.

Mathematica, 40 39 bytes

Thanks to Martin Büttner for saving 1 byte.

NestWhileList[⌊#^.5#^#~Mod~2⌋&,#,#>1&]&

Test case

%[5]
(* {5,11,36,6,2,1} *)

Oracle SQL 11.2, 128 bytes

WITH v(i)AS(SELECT :1 FROM DUAL UNION ALL SELECT FLOOR(DECODE(MOD(i,2),0,SQRT(i),POWER(i,1.5)))FROM v WHERE i>1)SELECT i FROM v;

Un-golfed

WITH v(i) AS
(
  SELECT :1 FROM DUAL
  UNION ALL
--  SELECT FLOOR(POWER(i,0.5+MOD(i,2))) FROM v WHERE i>1
  SELECT FLOOR(DECODE(MOD(i,2),0,SQRT(i),POWER(i,1.5))) FROM v WHERE i>1 
)
SELECT * FROM v;

Adding MOD(i,2) to .5 is shorter but there is a bug with POWER(2,.5) :

SELECT POWER(4,.5), FLOOR(POWER(4,.5)), TO_CHAR(POWER(4,.5)) FROM DUAL

gives

2   1   1,99999999999999999999999999999999999999

APL, 28 24 16 bytes

{⌊⍵*.5+2|⎕←⍵}⍣=⎕

This is a program that accepts an integer and prints the successive outputs on separate lines.

Explanation:

{           }⍣=⎕   ⍝ Apply the function until the result is the input
 ⌊⍵*.5+2|⎕←⍵       ⍝ Print the input, compute floor(input^(input % 2 + 0.5))

Try it online

Saved 8 bytes thanks to Dennis!

Haskell, 70 bytes

Haskell doesn't have integer sqrt built-in, but I think there may be something shorter than floor.sqrt.fromInteger.

s=floor.sqrt.fromInteger
f n|odd n=s$n^3|1<2=s n
g 1=[1]
g n=n:g(f n) 

Pyth, 14 12 bytes

.us@*B@N2NNQ

Demonstration

We start with a cumulative reduce, .u, which in this case starts at the input and applies a function until the result repeats, at which point it outputs all of the intermediate results.

The function takes the previous value as N. It starts by taking its square root with @N2. Next, it bifurcates that value on multiplication by N with *B ... N. This creates the list [N ** .5, (N ** .5) * N], the unfloored results for the even and odd cases. Next, the appropriate unfloored result is selected by indexing into the list with @ ... N. Since Pyth has modular indexing, no out-of-bounds errors are thrown. Finally, the result is floored with s.

TSQL, 89 bytes

Input goes in @N:

DECLARE @N INT = 5;

Code:

WITH N AS(SELECT @N N UNION ALL SELECT POWER(N,N%2+.5) N FROM N WHERE N>1)SELECT * FROM N

Julia, 64 50 48 42 32 30 bytes

g(x)=[x;x<3||g(x^(x%2+.5)÷1)]

This is a recursive function that accepts an integer and returns a float array.

We build an array by concatenating the input with the next term of the sequence, computed as x to the power of its parity plus 1/2. This gives us either x1/2 or x1+1/2 = x3/2. Integer division by 1 gets the floor. When the condition x < 3 is true, the final element will be a Boolean rather than a numeric value, but since the array is not of type Any, this is cast to have the same type as the rest of the array.

Saved 14 bytes thanks to Dennis!

Minkolang 0.15, 25 bytes

ndN(d$7;r2%2*1+;YdNd1=,).

Try it here!

Explanation

n                            Take number from input => n
 dN                          Duplicate and output as number
   (                         Open while loop
    d                        Duplicate top of stack => n, n
     $7                      Push 0.5
       ;                     Pop b,a and push a**b => n, sqrt(n)
        r                    Reverse stack => sqrt(n), n
         2%                  Modulo by 2
           2*                Multiply by 2
             1+              Add 1 => sqrt(n), [1 if even, 3 if odd]
               ;             Pop b,a and push a**b => sqrt(n)**{1,3}
                Y            Floor top of stack
                 dN          Duplicate and output as number
                   d1=,      Duplicate and => 0 if 1, 1 otherwise
                       ).    Pop top of stack and end while loop if 0, then stop.

JavaScript (ES7), 45 33 bytes

f=n=>n<2?n:n+","+f(n**(.5+n%2)|0)

Explanation

Recursive approach. Returns a comma-separated string of numbers.

f=n=>
  n<2?n:          // stop when n == 1
  n               // return n at the start of the list
  +","+f(         // add the rest of the sequence to the list
    n**(.5+n%2)|0 // juggler algorithm
  )

Test

** not used in test for browser compatibility.

f=n=>n<2?n:n+","+f(Math.pow(n,.5+n%2)|0)
<input type="number" oninput="result.textContent=f(+this.value)" />
<pre id="result"></pre>

Java 7, 83 71 bytes

void g(int a){System.out.println(a);if(a>1)g((int)Math.pow(a,a%2+.5));}

I originally used a typical for loop, but I had to jump through hoops to get it working right. After stealing borrowing user81655's idea to recurse instead, I got it down twelve bytes.

TI BASIC, 43 bytes

I'm pulling a Thomas Kwa and answering this one on my mobile.

Input N
Repeat N=1
Disp N
remainder(N,2->B
If not(B:int(sqrt(N->N
If B:int(N^1.5->N
End
1

Replace sqrt with the actual symbol on your calculator. Displays a linefeed separated list of numbers, which is a reasonable format.

JavaScript ES6, 109 102 bytes

s=>(f=n=>n==1?n:n%2?Math.pow(n,3/2)|0:Math.sqrt(n)|0,a=[s],eval("while(f(s)-1)a.push(s=f(s))"),a+",1")

I know this can be golfed. Returns a string of comma-separated numbers.