## 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.  ## You're forgetting about operator precedence.

All multiplicative operations (which include multiplication, division, and modulus) are performed before any additive opertions ( + or - ).

I'll bet you can figure it out now without a spoiler.  MOD

Ok so for Computer Science the Order of Operations is:

1. P ---> Parentheses
2. E ---> Exponents
3. M ---> Multiplication
4. D ---> Division (This is for programming only, division holds the same weight as multiplication
5. M ---> Modulos (This is for programming only, and it can has the same order weight as division and multiplication)
7. S ---> Subtraction

So by following these rules we know that our addition will be done last and our multiplication, division, and Modulos will be done first, so this could have effectively been written as `(8*7) + (8%5) + (6/2)`

We know that `8 * 7 = 56` We know that `8 % 5 = 3` We know that `6 / 2 = 3`

So when we add them all together we get `56 + 3 + 3 ----- or ----- 56 + 6 = 62` There's no common rule for all of "computer science", operator precedence varies with language. For example, in C#, multiplication does not take precedence over division — so 12/2*3 is 18, not 2. That is because of associativity, so you are correct there! I realized that I have not specified that division and modulos hold the same weight as multiplication so I will fix that. By the C# rules, the associativity of multiplicative operations is left-to right. That's why 12/2*3 evaluates to 18, instead of 2.

I recommend following the rules of the language you are programming in. If there are "general rules" that the language is "breaking", it doesn't seem like they would be useful to the developer and they could lead to confusion and unexpected program behavior. I see where you are coming from, I have a math background so I always see that there are general rules (keeps us sane) but in programming I have noticed that some languages seem to break this (for some reason or another). PEMDMAS does apply in Python where it's more like PE[MDM][AS]

```>>> 12 / 2 * 3
18.0  # not 2
>>> 12 / 4 % 2 * 3
3.0  # / then % then *
>>> 25 % 13 / 2 * 3
18.0 # % then / then *
>>> 15 - 3 + 2
14  # not 10
``` Normally the % (modulo) operator has the same level of precedence as multiplication and division. So in this statement we can evaluate it from left to right.

8*7 = 56 8%5 = 3 <- the remainder is the answer to a modulus expression 6/2 = 3 so... 56+3+3 = 62 PLUS

I like to put paranteses between numbers which are going to be multiplied, divided or modulated to seperate additive and multiplicative operations to make it easier:

(8*7)+(8%5)+(6/2)

This way you can easily solve it.

(56)+(3)+(3) = 62