A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Factorial in R page! Here, you'll find the source code for this program as well as a description of how the program works.
args<-commandArgs(TRUE)
if(length(args) > 0){
a = args[1]
# Check if String or numeral only, ..
numbers_only <- function(a) !grepl("\\D", a)
if(numbers_only(a) == TRUE){
if(a == 0){
cat("1")
}else if (a > 0){
fact = 1
for(i in 1:a){
fact = fact * i
}
cat(fact)
# else a < 0
} else{
cat("Usage: please input a non-negative integer")
}
# Negative Input
}else{
cat("Usage: please input a non-negative integer")
}
# Empty Command Line Param
}else{
cat("Usage: please input a non-negative integer")
}
Factorial in R was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.