Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Create a repeat-while loop increases growingValue by the square of its current value each time thru

Create a repeat-while loop that increases growingValue by the square of its current value each time through the loop as long as the result is less than 100. var growingValue = 2

4 Answers

So I think this is what they are looking for.

var growingValue = 2
var result = 0

while growingValue * growingValue < 100 {
    result = growingValue * growingValue
    growingValue = growingValue + result
}

or this also does it:

var growingValue = 2

while growingValue * growingValue < 100 {
    growingValue = growingValue * growingValue + growingValue
}

Unless by result it means after adding the square back to itself:

var growingValue = 2

while growingValue * growingValue + growingValue < 100 {
    growingValue = growingValue * growingValue + growingValue
}

The second and third versions are more concise so I would say one of those. Looks like it runs through the exact same number of time for both 2 and 3. They worded this one kind of tricky didn't they. Where are you getting these from, Tree House?

I added the specific repeat term to the body in my code below I think showing how the repeat is what was asking for.

I think all 4 are best answers

Also you can post your code blocks as below

```Swift
    //Code goes here
```    //Then 3 back ticks like this below

var growingValue = 2 var size = 100

repeat { print(growingValue) growingValue = growingValue * 2 } while growingValue < 100

I am taking exercises from lynda to practice.

really new to this.....where do I go to place code in the code pane? Workspaces?