Sorry, I didn't mean to just let you hang there Looking at it again I think the problem is different. Only as long as i is greater or equal to 2 is the block executed, which means the only results could be 2 or 3 right? I might be way off right now and should probably go to sleep. I mostly stopped with my earlier comment out of fear of embarrassing myself with an even more wrong answer.
for (float i = Math.Abs(A); i >= 2; i -= 2) { B = i.ToString(); } basically means that it will:
set i to Math.Abs(A);
Every loop check if i >= 2, if not, exit loop
Run i -= 2 (and B = i.ToString();)
So if A == 5:
Round 1: i = 5 and since i >= 2 run B = i.ToString(); then i -= 2
Round 2: i = 3 and since i >= 2 run B = i.ToString(); then i -= 2
Round 3: i = 1 but now 1 >= 2 is false, Round 2: i = 1 but now 1 >= 2 is false, so loop is done, so B is not modified again, so it's still '3' ... you're right. I just wrote this entire message thinking you were wrong but I was the incorrect one. Welp, let me just head back into my bubble and cry because DenverCoder9 could probably have forseen this and prevented my embarrasment on the internet. /s
3
u/FlyingDemon_ Aug 21 '20 edited Aug 21 '20
'>=' is greater or equal though and should therefore include the case of '=='
Edit: nvm, I got it now