inst/resources/scripts/nfact2.r

# function spuRs/resources/scripts/nfact2.r
# calculate n factorial

nfact2 <- function(n) {
    if (n == 1) {
        cat("called nfact2(1)\n")
        return(1)
    } else {
        cat("called nfact2(", n, ")\n", sep = "")
        return(n*nfact2(n-1))
    }
}

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.