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!
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
Berry Loeffen4,303 Points
about the 3%7 remainder. how come the answer is 3 as doesn't fit into 3 should it not be 0?
unclear how 3%7 equals 3 in stead of 0
Michael Reining10,101 Points
The answer is 3 because 7 does not fit into 3 as you said. Since it does not fit, you are left with everything (i.e. 3).
If you play in the playground in Xcode, you can see this yourself.
let answer1 = 3%2 // remainder = 1. 2 fits into 3 once and you are left with 1 let answer = 3%7 // remainder = 3. 7 does not fit so you are left with everything (3)
I hope that helps,
PS: Thanks to the awesome resources on Team Treehouse, I launched my first app.
Now you can practice writing Swift code directly on your iPhone :-)