Write JavaScript coding for: Program to print factorial of a number, accept number from the user.
Answers
Answered by
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
English,
2 months ago
Science,
2 months ago
Physics,
5 months ago
Math,
5 months ago
Computer Science,
10 months ago