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 trialJoe Pearson
1,675 PointsI don't understand the modulus operator. how do you perform this on a calculator? how are you getting the answers?
I don't understand the modulus operator. how do you perform this on a calculator? how are you getting the answers?
2 Answers
joelearner
54,915 PointsHi Joe,
The modulus is the remainder from a division operation. So if you have 15/5, you will get 3 and no remainder. The modulus is 0 here. Or if you have 18/4, you will get 4 and a remainder of 2. The modulus here is 2.
For example, if you had this: 5 * 2 + 9 % 4 + 8 / 4 Then you have 5 * 2 = 10, 9 % 4 = 1, 8 / 4 = 2 or 10 + 1 + 2 and your answer will be 13.
Cheers!
Joe Pearson
1,675 Pointsthank you! I also discovered that if you're doing this on a calculator it will give you a decimal. to convert to the remainder, your multiply the decimal to the divisor. Thanks!
Allan Clark
10,810 PointsIf joelearner provided helpful information and answered your question please take the time to upvote his answer and select as 'Best Answer', it will mark this question as closed and give him some swag points for his time :)
Happy Coding!