Question
Write a function in R script which calculates the factorial of any non-negative integer n (you may NOT use the built-in factorial function). Consider the
Write a function in R script which calculates the factorial of any non-negative integer n (you may NOT use the built-in factorial function). Consider the following things in the construction of your function: Zero factorial is defined to be 1 The factorial, for positive integers, is recursive in nature. You should use a FOR loop to calculate the factorial. The factorial is not defined for negative numbers. Add in a check in you function which returns an error message to the user in the case that n is negative. Use your factorial function to compute the following factorials: 3!, 10!, and 50!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started