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
Dejuan Castro198 Points
Does this mean %3 ==0 no remainders ?
So, in this practice problem I think I'm misunderstanding % (percent sign). is_fizz = number %3 == 0 Since the goal is to say fizz if it's divisible by 3 . Why wouldn't we put is_fizz = number /3 ???
From the docs
The % (modulo) operator yields the remainder from the division of the first argument by the second
So if the remainder of the first number divided by the second is zero the first number is perfectly divisible by the second. That is the goal for the fizzbuzz challenge. number /3 will only equal zero if number is zero. This doesn't show you anything since every number is divisible by every number (unless you want to exclude division by zero). If number is positive then number/3 is positive and comparing to zero will always be false.
For example 21 divided by 3 is 7 with no remainder (or remainder = 0).
21%3 == 0 is the same as 0 == 0 and would evaluate to true
21/3 == 0 is the same as 7 == 0 and would evaluate to false