Hi Harry,
"For loops" are great for if you want to do something a certain number of times. In this case, we wanted to alter the variables first, second, and current until we reached the number n (which is the input value). For loops have this syntax where you declare a variable (in this case, i), initialize its starting index (in this case, 2), set its condition to keep executing (in this case, keep executing as long as i < n), and state how the variable will be updated each time we go through the loop (in this case, i increments every time we go through the loop). The syntax i++ is the shorthand for i = i + 1. You can find a longer explanation here. Hope this helps!
What does the i and the i++ mean in the final image? I don't see any explanation for it. I was with you up until that point. Thanks.
Hi Harry,
"For loops" are great for if you want to do something a certain number of times. In this case, we wanted to alter the variables
first,second, andcurrentuntil we reached the numbern(which is the input value). For loops have this syntax where you declare a variable (in this case,i), initialize its starting index (in this case, 2), set its condition to keep executing (in this case, keep executing as long asi < n), and state how the variable will be updated each time we go through the loop (in this case,iincrements every time we go through the loop). The syntaxi++is the shorthand fori = i + 1. You can find a longer explanation here. Hope this helps!Ah, I think I understand now. It's sort of like a counter ?