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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Alia Khan](https://secure.gravatar.com/avatar/d999023a07d2bfc714991bb814859ab9?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Alia Khan
3,733 PointsWorking with logical operators challenge
What have I done wrong here?
Thank you
var results: [Int] = []
for n in 1...100 {
// Enter your code below
if n % 2 != 0 && n * 7 == 0 {
results.append(n)
}
// End code
}
1 Answer
![Jennifer Nordell](https://uploads.teamtreehouse.com/production/profile-photos/5432702/micro_jen-square.jpg)
Jennifer Nordell
Treehouse TeacherHi there, Alia! The operator between the n and the 7 is incorrect. That's a multiplication operator. To check if something is equally divisible by a number we use the modulus operator (which you did perfectly when checking for an odd number). Any number % 2 is going to return a 0 or a 1. Five modulus 2 will return a 1 because two goes into five twice with a remainder of one. So all odd numbers will have a one.
To see if a number is evenly divisible by 7 you need to employ the same tactic. 13%7 will return a 6 because 7 goes into 13 once with a remainder of 6. Thus, it isn't evenly divisible. Fourteen modulus 7 will return a 0 as seven goes into fourteen twice with a remainder of 0.
For any number x % y we say that x is evenly divisible by y when the number returned from this operation is 0.
Try again with these hints in mind!