Hello im trying to do a simple factorial loop here. and im wondering why does i==something not work as a proper condition? Or am i doing something wrong
Okay here is the code. i understand the difference between = and ==
1 2 3 4 5 6 7
for(int i = 4; i >= 1; i--)
{
factorial = factorial * i;
cout<<factorial<<" ";
}
So my problem is that while this above works... What i at first wanted to do was i == 1 for the condition and it doesnt work which makes no sense to me...
yes thats the same thing but factorials decrease so it just made sense in my mind to decrease. All i am trying to ask is regarding the for loop condition.
@Asthar:
hey, he put for(int i = 4; i >= 1; i--)
so the condition is "run as long as i is bigger than 1 or equal to 1"
and 4 meets this condition, 4 > 1, so it will enter the loop, right?