I am trying to print out the Factorial process such as 6!: Console output:
Function returned: 6! = 1*2*3*4*5*6 = 720
However, I couldn't figure it out. There are two kind of problems in my code: when the loop finishes, I get one extar "star" like [...] 6*; the outputs order is not as I want it to be.
I have tried two ways; niether of them work as I want.
That's what I am trying to figure it out, but I couldn't. If I change the count strarts the factorial result would be wrong since one loop would be missing.
That works. The solution we were hinting at was this:
1 2 3 4 5 6
for (i = 1; i <= n; i++)
{
sum = sum * i;
if( i != n ) // Last time through this loop, i == n (because i + 1 is > n, loop terminates)
cout << i<< "*";
}