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

iOS Swift Collections and Control Flow Control Flow With Conditional Statements Working With Logical Operators

operators.swift i dont understand the following sense !

i nee some help to resolve this sense....

var results: [Int] = []

for n in 1...100 {


2 Answers

Hi Diogo!

So, in this challenge you have a range from 1 to 100. And in this range you have to find numbers which are both odd and a multiple of 7 Odd numbers are numbers like 1, 3, 5, 7, 9 etc. In other words, it's the opposite of even numbers (2, 4, 6, 8 ..., simply numbers which are a multiple of 2). Multiple of number x is such number that if you divide this number by x, there is nothing left Example: 14/7 = 2 (nothing's left so 14 is a multiple of number 7) 15/7 = 2 (and there's left 1 because 2*7=14 and you need to add 1 to have 15) In code it's like this: x%7==0 ("what's left of this dividing is equal to 0"). And with the odd numbers it's similiar. First, you have to find numbers which are a multiple of 2 and then negate it (!=)

Hopefully this will help you. If you have any questions, just ask :)

I'm stilling lost unfortunately !! i don't understand what command i need to use for it...

swift_lint.swift:10:4: error: expected expression in != 1 ^

i have this follow problem and i can't know why....

So, I did this challenge and this is what you should write:

if n%7==0 && !(n%2==0) {

Look at the code and if you don't understand me, tell me and I will explain it.

Anyway, it's quite weird that this way it doesn't work:

if n%7==0 && n%2!=0 {

If somebody knows why, I will be more than happy for explanation :)