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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!