Write a javascript program to find factorial of a given number
Answers
Answer: A programme to find a number's factorial is in the format /.
Explanation: / request input from the user
enter a positive whole number: prompt; const number = parseInt;
In the event that the number is negative, check
in the unlikely event that (number 0)
Factorial for a negative integer is invalid, console.log("Error!");
}/ if that number is 0, thenIf not, then (number === 0)
The factorial of $number is 1, according to console.log;if that number is positive, then
otherwise {
Suppose reality is 1;
for (I = 1; I
truth * = I;
The factorial of $number is $fact, according to console.log();}
To get the factorial of a given number, we are iterating a loop over the list of integers. Memory usage while using this method is lower than when using a recursive implementation. The code, however, is longer than the recursive approach.
#SPJ2