KLSfactorial <- function(x) { y <- 1 for(i in 1:x) { y <- y * ((1:x)[i]) } print(y) } KLSfactorial(12)