Skip to main content
2 of 3
added 35 characters in body
Nick Kennedy
  • 21.2k
  • 3
  • 17
  • 43

R >= 4.1, 81 bytes

\(x,y=x){while(x>1)y=c(y,x<-c(x/2,3*x+1)[x%%2+1]);plot(y,c(y[-1],NA),"l")}

Try it at RDRR.io!

Note this uses RDRR because TIO doesn’t support graphical output. It also uses function in place of \ since RDRR doesn’t support R 4.1.0 yet.

Thanks to @DominicVanEssen for saving 7 bytes!

Nick Kennedy
  • 21.2k
  • 3
  • 17
  • 43