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 trialZenek Barburka
7,009 PointsClosest multiple of 6 for 32 is 36?
I understand that it's just an example ilustrating the concept, but as it is content for which I pay I would like it to be without basic errors like this one.
1 Answer
Ryan S
27,276 PointsHi Zenek,
It is not so much an error regarding the concept of multiples, but more to do with the fact that the function is written in a such a way that it will always return the closest multiple of 6 that is greater than the value you give it. In other words, it does exactly what it is supposed to, regardless of its name.
The logic basically is "if the current multiple in the range of multiples is greater than the value AND the difference between them is less than 6, then return the multiple". The function doesn't consider the case for which it is less than the value.