inst/resources/scripts/threexplus1array.r

# program spuRs/resources/scripts/threexplus1array.r

x <- 3
for (i in 1:3) {
  show(x)
  if (x[i] %% 2 == 0) {
    x[i+1] <- x[i]/2
  } else {
    x[i+1] <- 3*x[i] + 1
  }
}
show(x)

Try the spuRs package in your browser

Any scripts or data that you put into this service are public.

spuRs documentation built on May 2, 2019, 12:44 p.m.