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 trialEric Witowski
Courses Plus Student 92 PointsCreate 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
Brandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsSo 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
}
Eric Witowski
Courses Plus Student 92 Pointsvar growingValue = 2 var size = 100
repeat { print(growingValue) growingValue = growingValue * 2 } while growingValue < 100
Eric Witowski
Courses Plus Student 92 PointsI am taking exercises from lynda to practice.
Eric Witowski
Courses Plus Student 92 Pointsreally new to this.....where do I go to place code in the code pane? Workspaces?
Brandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsBrandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsThe 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?
Eric Witowski
Courses Plus Student 92 PointsEric Witowski
Courses Plus Student 92 PointsI 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
Brandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsBrandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsAlso you can post your code blocks as below