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 Swift Collections and Control Flow Control Flow With Conditional Statements Working With Logical Operators

I need help with this if statement :(

I don't understand how to check for multiples of 7 and if they're odd using the "!" operator, please guide me through setting this up correctly.

var results: [Int] = [7,21,35,49,63,77,91]
var multiples: [Int] =[7,14,21,28,35,42,49,56,63,70,77,84,91,98]
for n in 1...100 {
    // Enter your code below
    if results && multiples {
    print("not even")
    // End code 

1 Answer

james south
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

you use the modulo operator %. modulo returns the remainder of division. when numbers evenly divide, there is no remainder and modulo returns 0. if a number % 2 is 0, it is even. if 1, odd. here it looks like they specifically want you to use the not operator ! so a !0 from a % operation would be an odd number. for the 7s, it works the same way. if a number mod 7 is 0, dividing the number by 7 leaves no remainder and thus the number is evenly divisible by 7.