Skip to main content
New byte count was missing
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

R >= 4.1, 81 74 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!

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!

R >= 4.1, 81 74 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!

added 35 characters in body
Source Link
Nick Kennedy
  • 21.2k
  • 3
  • 17
  • 43

R >= 4.1, 8181 bytes

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

Try it at RDRR.io!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!

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[-sum(y|1)],y[-1],t="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.

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!

Source Link
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[-sum(y|1)],y[-1],t="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.