local({ previous_options <- options(warn = 2, digits = 8, stringsAsFactors = FALSE) on.exit(options(previous_options), add = TRUE) sum_to <- function(n) { if (!is.numeric(n) || length(n) != 1L || is.na(n) || !is.finite(n) || n < 0 || n > 20 || n != floor(n)) { stop("Use one integer from 0 to 20") } if (n == 0) return(0) n + sum_to(n - 1) } cat("zero:", sum_to(0), "four:", sum_to(4), "\n") invisible(NULL) })