Question: Write a method that calculates the factorial of a given number. Factorial is the product of all positive integers less than or equal to

Write a method that calculates the factorial of a given number. Factorial 

Write a method that calculates the factorial of a given number. Factorial is the product of all positive integers less than or equal to n. For example, factorial(4) = 4x3x2x1 = 24. TIP: To make it more interesting, try to do it recursively. public Integer factorial(Integer n) { int factorial = n; for (int j=n-1;j> 0; j--) { factorial factorial *j; } } return factorial; Input(n) 1 6 8

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 Programming Questions!