Q:

Write a method that calculates the factorial of a given number

belongs to collection: java exercises (easy level )

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

public Integer factorial(Integer n) {
int factorial = n;
for (int j = n - 1; j > 0; j--) {
    factorial = factorial * j;
}
return factorial;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

using Linear Search ,Write a method that returns t... >>
<< Given a number n, write a method that sums all mul...