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 trialMichael Cafin
iOS Development Techdegree Student 1,221 PointsRequest for subtle hint
As am I understanding what they are asking, I am having trouble what types are needed on how to find the "odd" numbers and on how to find the multiple of 7s by using the if statement.
NOTES: it states that for finding the odd numbers to use the NOT operator, but what target would I use?
I have checked my notes but could not find an example. If someone could give me a subtle hint it would be much appreciated.
var results: [Int] = []
for n in 1...100 {
// Enter your code below
// End code
}
3 Answers
David Papandrew
8,386 PointsJust to build on the other response:
10 % 2 == 0 //resolves to true
9 % 2 == 0 //resolves to false
n % 2 == 0 //resolves to true or false depending on the value of n
Michael Cafin
iOS Development Techdegree Student 1,221 PointsThx for responding David for the add-on! It is much appreciated. I will check later today how to implement your suggestions!
I'll keep you posted!
Michael Cafin
iOS Development Techdegree Student 1,221 PointsThx for responding Alex. Will check later today how to implement your suggestions!
I'll keep you posted!
Michael Cafin
iOS Development Techdegree Student 1,221 PointsMy apologies for the wait but I want to thank both of you. It was truly helpful!
This is what I came up with
for n in 1...100 { if n % 7 == 0 && n % 2 != 0 { results.append(n) } }
Alex Yakir
5,425 PointsAlex Yakir
5,425 PointsFrom what I understand, you need to find all the odd numbers that are divisible by 7 between 1-100.
For that you can use an "If" statement that checks two conditions:
Hope this hint is subtle enough.