## 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.

# For this challenge, we'd like to know in a range of values from 1 to 100, how many numbers are both odd, and a multiple

Can you help me out on this guys I'm stuck

var results = 20

for n in 1...100 { // Enter your code

```  //End code
```

}

operators.swift
```var results: [Int] = [20]

for n in 1...100 {

// End code
}
```

This will make you pass the challenge. I would take look at the videos again or restart some of the older parts of logical operators. Especially for foundational material like this.

```var results: [Int] = []

for n in 1...100 {
if (n % 2 != 0) && (n % 7 == 0) {
results.append(n)
}
}
```

the logic I wrote earlier would still apply

Hi Shariff for this challenge you have to get a number and append it to the results array if its odd and a multiple of 7. To check to see if a number is divisible you can use the modulo operator (%) and see if the remainder is 0. If the remainder is 0 then the two numbers are perfectly divisible.

```let example = 25 % 5
// 5 divides into 25 perfectly 5 times so there is no remainder that means they're perfectly divisible

// to check if a number is a multiple of 7

let randomNumber = 49 % 7 == 0
```

You also check to see if a number is odd. For this one its the same idea using the modulo operator( % ) but you will use the logical operator not equal ( != ). This logical operator means not equal to.

```let example = 25 % 2 != 0
//if you put this on a playground it will say true on the right hand side because 25 is an odd number.
```

Since these are the two parts of the if statement you write you must combine them with the and logical operator ( && ). If both conditions are true the code executes if even one is not true the code doesn't run.

```if (49 % 7 == 0)  && (25 % 2 != 0) {
}

lastly to append to the results array use dot notation and ( ) to append n to the results array.

```swift
let results: [Int] = [ ]

// we need to put :[Int] since its an empty array and the compiler needs to know the type since this is an empty array

example.append( )
```

hope this helps !

Thank you but I'm still having challenges on this

What part is confusing maybe I can explain it differently

For real this part its a beat difficult to me i have almost a week trying to work on it but its kinda trick

At least now i know where its going but im in a war with that

Cheers l see i was not using .append

ah I see yeah at the end they want you to append n to the empty array glad you passed it !

Yeah Jonathan thank you so much lemme try to work until i reach your level

happy to help learning to code is just time and practice I don't know everything either