Every time I execute the code, it doesn't actually perform the multiplication of my number. Instead, it continues to output in a loop until it reaches 1.
I've attempted various methods and this one is the most promising so far.
......................................
var BR="<br />"; //html line break
function factorial(Num) {
document.write("The factorial of your number is" +Num +BR);
if (Num == 1 ) return 1;
else return (Num * factorial(Num-1));
}
.....................................................
.......................................
var Num; //users number
var Numfactorial;
var ES="";
var factorial
Num=prompt("Enter a number between 1-20" +ES);
Numfactorial=factorial(Num);
.........................................
The intended functionality is to take the input number and recursively multiply it down - for example, entering 20 should result in: 20*19*18... continuing until it reaches 1 and then outputs the final product.