0
Factorial Problem in JavaScript
A factorial problem in JavaScript If the input number is 4, I got answer like 4 12 24 24 The answer should be just 24. What should I change in the code? My code is below. function main() { var number = parseInt(readLine(), 10) var factorial = 1; for(number ; number >= 1 ; number-- ) { factorial = factorial * number console.log(factorial) } // Your code here }
3 ответов
+ 3
Print output after for loop..
(put console.log(factorial) outside loop, not within loop...)
+ 1
Got it!! Thank you!
0
You're welcome...