Computer Science, asked by SoorajNair2803, 5 months ago

Write JavaScript coding for: Program to print factorial of a number, accept number from the user.​

Answers

Answered by Ruthbriana1234
1

Answer:

Explanation:

1. The iterative approach ..

  • function factorial(n){
  • let answer = 1;
  • if (n == 0 || n == 1){
  • return answer;
  • }else{
  • for(var i = n; i >= 1; i--){
  • answer = answer * i;
  • }

Hope this helps

Similar questions