Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 402 characters in body
Source Link
user85052
user85052

Keg -rR, 2823 bytes (SBCS)

I really need to remember those new instructions.

0&{:1>|:2%[3*9|1⁄2]&9&}_&2%[3*9|1⁄2](6)

Try it online! Try it online!

Explanation

0& # Set 0 to the accumulator
 {:1> # While the number is not 1:
 |:2% # Is the number divisible by 2?
 [3*9 # If not, multiply by 3 & increment
 |1⁄2] # Otherwise, halve the number
 &9& # Increment the accumulator
 }_ # Discard the number
 & # Push the accumulator & implicit output

Keg, 28 bytes (SBCS)

0&{:1>|:2%[3*9|1⁄2]&9&}_&

Try it online!

Explanation

0& # Set 0 to the accumulator
 {:1> # While the number is not 1:
 |:2% # Is the number divisible by 2?
 [3*9 # If not, multiply by 3 & increment
 |1⁄2] # Otherwise, halve the number
 &9& # Increment the accumulator
 }_ # Discard the number
 & # Push the accumulator & implicit output

Keg -rR, 23 bytes (SBCS)

I really need to remember those new instructions.

0&{:1>|:2%[3*9|1⁄2](6)

Try it online!

Source Link
user85052
user85052

Keg, 28 bytes (SBCS)

0&{:1>|:2%[3*9|1⁄2]&9&}_&

Try it online!

Explanation

0& # Set 0 to the accumulator
 {:1> # While the number is not 1:
 |:2% # Is the number divisible by 2?
 [3*9 # If not, multiply by 3 & increment
 |1⁄2] # Otherwise, halve the number
 &9& # Increment the accumulator
 }_ # Discard the number
 & # Push the accumulator & implicit output

AltStyle によって変換されたページ (->オリジナル) /