I have a piece of code that calculates the factorial of a number in JavaScript, but I wanted it to return the steps of each calculation, eg:
3! = 1x2x3 = 6
Follow the code I made. I tried to "print" decrementing the variable, but I'm not sure what I'm doing.
var fatorial=1;
var num=parseInt(prompt("Digite um número: "));
for(var x=1; x<=num; x++)
{
fatorial=fatorial*x;
}
document.write(num+"! = "+num+"x"+(num--)+"="+fatorial);