## tanya53 3 years ago exercise 1.15, I get the problem and what prints out, but what is the sequence of numbers that the guy wants to print or what would the sequence be used for, second part of the exercise?

• This Question is Open
1. hook

I don’t completely understand which sequence you’re talking about, but I did find the Exercise 1.15 a lot more sensible when I did also the optional part of it.

2. andrew.m.higgs

I also struggled to understand what the program was intended to do. I guess this illustrates the importance of commenting code.

3. SJKramer

Can you solve it just by using commenting code or do you need to tinker with the code as well?

4. andrew.m.higgs

I don think just commenting will do. Changing the while loop or putting in an if statement to break the while loop is the most likely. Having said that, it its difficult to "fix" the code when we don't really know what the hoped for outcome is.

5. petew71

I wasn't sure on this? I assumed that because there was a' %2==0' and an' i/2', it was something to do with even numbers. But what about n? I made it so i printed even numbers 10 down to 2. And n printed odd numbers 3 up to 9....Just as an experiment.

6. hook

I see two possible solutions for the buggy loop: (v1) counts down 'n' to make 10 iterations, while the second (v2) makes 'i' smaller by 1 each time it’s odd, and therefore reaches 0 and breaks the loop.

7. thoughtcrimes

Yes, it runs as an infinite loop the way it is written, and never uses the N = 10 variable. So, you could use the N as a counter to how many times to run the code, or figure out what the code might be trying to do differently. It kind of reminds me of the square root problem discussed in one of the videos.