inst/testdata/prov_factorial_2021-04-26T16.34.16EDT/scripts/factorial.R

factorial <- function (num) {
  if (num < 0) {
    return (-1)
  }
  
  if (num == 0) {
    return (1)
  }
  
  return (num * factorial (num - 1))
}

cat ("The factorial of", 5, "is", factorial (5), "\n")
cat ("The factorial of", -5, "is", factorial (-5), "\n")
cat ("The factorial of", 0, "is", factorial (0), "\n")
End-to-end-provenance/provExplainR documentation built on Aug. 19, 2022, 1:15 a.m.