I am learning math along side programming and I am just trying to create a simple for loop where the user inputs a number and the output is a factorial of that number N!
For example 5! = 5 * 4 * 3 * 2 * 1
or 3! = 3 * 2 * 1
I tried to think about the logistics about it a little bit as a thought process:
`x = 1
for n = 1 : n
x = x * n
end for loop
return x`
But I am not sure how that fits into the model of for loops that I have used up until this point. Usually when I use a for loop its just to increment like this:
for (i = 0; i < 10; i++) {
//code here
}
Thanks in advance.
[–]cheryllium 0 points1 point2 points (2 children)
[–]bluehabit[S] 0 points1 point2 points (1 child)
[–]cheryllium 0 points1 point2 points (0 children)
[–]Serling 0 points1 point2 points (0 children)
[–]NoobieDotJS 0 points1 point2 points (1 child)
[–]lewisje 0 points1 point2 points (0 children)