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

Stuck in challenge 1 of 1 in Swift Collections and Control Flow

I do not know what to do here. I think some of the problem is that English is not my first language. I do not know what "a multiple by 7" means. But can anyone point me in the right direction. Where should I start?

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

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

    // End code 
}

3 Answers

So a multiple is a number that when divided by a given number will not have a remainder. For example 14 is a multiple of 7 because 14 divided by 7 is 0. You use the % sign find the remainder of two numbers.

Below n % 2 will find if it is odd or even and n % 7 will find if it is a multiple of 7.

var results: [Int] = []

for n in 1...100 {
    // Enter your code below
    if n % 2 != 0 && n % 7 == 0 {
      results.append(n)
    }
    // End code 
}
Sarah Hurtgen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Sarah Hurtgen
Treehouse Project Reviewer

Hi! I believe the task would be wanting you to multiply (times) a range of numbers by 7. For example, if the multiplier was 2, it would read: 2 * 7

Hopefully that helps point you in the right direction. If you need further help with this specific challenge, it would be great if you posted a direct link to it for us to be able to see the exact requirements.

Best luck! :)

Thank you both! There may be some problem with the language sometimes, but it helps to get it explained :)