The foundation of all mathematics. Master these concepts and every topic that follows will make sense. No prior knowledge required -- we start from scratch.
If you're new to math or feeling rusty, take your time with this section. Work through every example step by step. Practice with pencil and paper, not just reading. Math is like learning to drive -- you need hands-on practice, not just theory. Aim for understanding "why" something works, not just memorizing steps.
Let's be real: reading this site alone will not make you good at math. Reading gives you familiarity. Practice gives you skill. These are completely different things. Here's how to actually build strength:
The bottom line: This site is a strong reference and learning guide. If you follow it with dedication AND work the practice problems with pencil and paper AND use external sites for more problems, yes, you will build a solid foundation. If you just read through it, you'll feel like you understand but struggle to apply it under pressure. The difference is always practice.
"This is just basic math, why do I need it for CS?" Because every line of code you write is math in disguise. Here's how each topic on this page maps directly to programming:
int, float, double, unsigned). Understanding which numbers fit where prevents bugs like integer overflow.3 + 4 * 2 using BODMAS. Get it wrong and your program produces the wrong answer silently -- the worst kind of bug.0.1 + 0.2 == 0.30000000000000004 in JavaScript? You need to understand decimals to understand why.O(n^2), O(2^n)), powers of 2 (memory sizes: 1KB = 2^10 bytes), exponential growth in algorithms.arr[-1]), coordinate systems in games, temperature sensors, financial calculations, two's complement binary.% operator: hash tables, circular buffers, FizzBuzz, cryptography, pagination, checking even/odd -- you'll use mod more than any other math in code.ceil(items/perPage)), memory alignment, dividing work across threads.You are not just "learning basic math." You are building the mental model that every programming concept sits on top of.
"Truly smart" is not a destination you arrive at. It's a daily practice. The people you look at and think "they're brilliant" -- they still struggle with new material, still forget things, still get stuck. The difference is they've been doing the reps longer and they don't quit when it gets hard.
Motivation is what you feel right now. It will fade. Every single person who commits to learning something hard hits a wall where it stops being exciting and starts being boring, repetitive work. That's where most people quit. The ones who get strong are the ones who show up on the days they don't feel like it.
There are no shortcuts. The people who are strong in CS and math put in the work consistently over a long period. Not in bursts of motivation followed by weeks of nothing -- consistently. Small amounts, daily, for a long time, beats intense cramming every time. The content is here. The practice problems are here. The external resources are linked. The only variable left is whether you actually sit down and do it, day after day, especially on the days you don't want to.
Before we do anything with numbers, let's understand what kinds of numbers exist. Think of it as a family tree -- each type builds on the last one.
These are the numbers you first learned as a kid: 1, 2, 3, 4, 5, ... and so on forever. They are called "natural" because they feel, well, natural. You use them to count things: 3 apples, 7 dogs, 42 stars. Natural numbers never include zero, fractions, or negatives.
Natural numbers in daily life: counting money (5 dollars), measuring quantity (3 apples), expressing age (25 years old), house numbers (123 Main St). These are the numbers that feel most "natural" because we use them constantly for counting discrete things.
Take all the natural numbers and add zero. That is it -- you now have the whole numbers. Zero is special because it represents "nothing," but it is still a valid number.
Now extend whole numbers in the other direction -- add all the negative whole numbers. Integers include numbers like -3, -2, -1, 0, 1, 2, 3. No fractions, no decimals -- just clean whole values, both positive and negative.
Picture a horizontal line stretching forever in both directions. Place 0 in the center. Positive numbers go to the right (1, 2, 3, ...) and negative numbers go to the left (-1, -2, -3, ...). Every integer sits at an exact point on this line, spaced evenly apart.
... -4 -- -3 -- -2 -- -1 -- 0 -- 1 -- 2 -- 3 -- 4 ...
A rational number is any number that can be written as a fraction of two integers (where the bottom number is not zero). This includes all integers (because 5 = 5/1), all fractions (like 3/4), and all terminating or repeating decimals (like 0.75 or 0.333...).
These are numbers that cannot be written as a fraction of two integers. Their decimal expansions go on forever without repeating. The most famous examples are pi and the square root of 2.
Put all rational and irrational numbers together and you get the real numbers. This is every possible point on the number line. Basically, if you can point to it on a number line, it is a real number.
| Type | Includes | Examples |
|---|---|---|
| Natural | Positive counting numbers | 1, 2, 3, 100, 9999 |
| Whole | Natural numbers + zero | 0, 1, 2, 3, 100 |
| Integer | Whole numbers + negatives | -5, -1, 0, 3, 42 |
| Rational | Any number expressible as a/b | 1/2, -3, 0.75, 0.333... |
| Irrational | Non-repeating, non-terminating decimals | pi, sqrt(2), e |
| Real | All of the above combined | Everything on the number line |
Natural numbers are inside whole numbers, which are inside integers, which are inside rational numbers, which are inside real numbers. Each set contains the previous one plus more.
Try to classify these numbers (some fit multiple categories):
Key insight: Every natural number is also whole, integer, rational, and real. But not every real number is natural.
In programming, you choose a data type based on what kind of number you need -- and this directly maps to the number types above:
unsigned int in C++ (no negatives allowed, just 0 and up)int, long (positive and negative whole numbers)float, double (numbers with decimal points)float/double, but they get rounded because computers can't store infinite decimals. That's why π in code is 3.14159265... and stops at some point.Picking the wrong type causes real bugs. Storing a negative number in an unsigned int wraps it to a huge positive number. Storing money as a float causes rounding errors (use integers counting cents instead).
Knowing your times tables by heart is like knowing the alphabet -- it makes everything else in math much easier. You don't want to be calculating 7 × 8 from scratch every time; you want it to be automatic. Let's master all multiplication facts from 1 to 12.
The key is daily practice. Spend 5-10 minutes each day on times tables. Start with the easy ones (2s, 5s, 10s), then work your way up. Say them out loud. Write them down. Use the interactive quiz below every day until they become automatic.
Here's the full multiplication table. Notice the patterns -- the table is symmetrical because 3 × 7 = 7 × 3 (the commutative property).
| × | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 2 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 |
| 3 | 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 | 33 | 36 |
| 4 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 |
| 5 | 5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 |
| 6 | 6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 | 60 | 66 | 72 |
| 7 | 7 | 14 | 21 | 28 | 35 | 42 | 49 | 56 | 63 | 70 | 77 | 84 |
| 8 | 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 88 | 96 |
| 9 | 9 | 18 | 27 | 36 | 45 | 54 | 63 | 72 | 81 | 90 | 99 | 108 |
| 10 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 110 | 120 |
| 11 | 11 | 22 | 33 | 44 | 55 | 66 | 77 | 88 | 99 | 110 | 121 | 132 |
| 12 | 12 | 24 | 36 | 48 | 60 | 72 | 84 | 96 | 108 | 120 | 132 | 144 |
Any number times 1 equals itself. 7 × 1 = 7. This is the easiest table!
Double the number. 2 × 6 = 12 (just 6 + 6). If you can add, you can multiply by 2.
Triple a number = double it + add the original. 3 × 7 = 14 + 7 = 21
Double the number, then double the result. 4 × 6 = 2 × 12 = 24. Or: 6 → 12 → 24
Multiply by 10, then halve. 5 × 7 = 70 ÷ 2 = 35. Or: results always end in 0 or 5.
When you multiply an even number by 6, the answer ends in the same digit. 6 × 2 = 12, 6 × 4 = 24, 6 × 6 = 36, 6 × 8 = 48
No easy trick -- just memorize. Focus on the tricky ones: 7 × 7 = 49, 7 × 8 = 56, 7 × 6 = 42. Memory trick for 7 × 8: "5, 6, 7, 8" → 56 = 7 × 8
Double, double, double. 8 × 3 = 3 → 6 → 12 → 24. Or use: 8 × n = 4 × n × 2
Magic pattern: For 9 × n, the digits add up to 9. 9 × 3 = 27 (2+7=9), 9 × 7 = 63 (6+3=9).
Finger method: Hold up 10 fingers. To find 9 × 4, put down finger 4. Count fingers on each side: 3 on left, 6 on right = 36!
Pattern: 9, 18, 27, 36, 45, 54, 63, 72, 81, 90. Notice the tens go up (0,1,2,3...) and units go down (9,8,7,6...).
Just add a 0 to the end. 10 × 7 = 70. The easiest after × 1!
For single digits: 11 × 3 = 33, 11 × 7 = 77. For 10+: 11 × 12 = 132 (use normal multiplication or 12 × 10 + 12).
Use: 12 × n = 10 × n + 2 × n. Example: 12 × 7 = 70 + 14 = 84.
These are the facts most people struggle with. Focus extra practice here:
Practice makes perfect! Use this quiz every day. Try to answer in under 3 seconds per question.
Loading...
Score: 0 / 0 | Streak: 0
Daily goal: Get 20 questions right with at least 90% accuracy. Once you can do this consistently, you've mastered your times tables! Focus on speed -- aim to answer each question in under 3 seconds.
Cover the answers. Write each answer down as fast as you can. Time yourself. Your goal: all correct in under 2 minutes.
1) 7 x 8 2) 6 x 9 3) 12 x 11 4) 8 x 6 5) 9 x 7
6) 4 x 12 7) 11 x 8 8) 3 x 9 9) 7 x 7 10) 6 x 6
11) 8 x 9 12) 12 x 7 13) 5 x 11 14) 9 x 9 15) 6 x 8
1) 56 2) 54 3) 132 4) 48 5) 63
6) 48 7) 88 8) 27 9) 49 10) 36
11) 72 12) 84 13) 55 14) 81 15) 48
1) 7 x 6 2) 8 x 7 3) 9 x 6 4) 12 x 8 5) 11 x 7
6) 9 x 8 7) 7 x 9 8) 6 x 12 9) 8 x 8 10) 12 x 9
11) 7 x 12 12) 9 x 11 13) 8 x 12 14) 6 x 7 15) 11 x 12
1) 42 2) 56 3) 54 4) 96 5) 77
6) 72 7) 63 8) 72 9) 64 10) 108
11) 84 12) 99 13) 96 14) 42 15) 132
1) 56 / 8 2) 72 / 9 3) 48 / 6 4) 81 / 9 5) 132 / 11
6) 63 / 7 7) 96 / 12 8) 54 / 6 9) 84 / 7 10) 108 / 9
1) 7 2) 8 3) 8 4) 9 5) 12
6) 9 7) 8 8) 9 9) 12 10) 12
When you see an expression like 3 + 4 x 2, do you add first or multiply first? The answer matters -- and getting it wrong is one of the most common mistakes in math. The order of operations tells you exactly which calculations to do first.
There are two popular acronyms. They mean the same thing, just different words:
| BODMAS | PEMDAS | Meaning | Priority |
|---|---|---|---|
| Brackets | Parentheses | Solve inside ( ) first | 1st (highest) |
| Orders | Exponents | Powers and roots (x^2, sqrt) | 2nd |
| Division | Multiplication | Multiply and divide, left to right | 3rd (equal priority) |
| Multiplication | Division | ||
| Addition | Addition | Add and subtract, left to right | 4th (equal priority) |
| Subtraction | Subtraction |
Multiplication and division have equal priority -- you do them left to right. Same for addition and subtraction. It is NOT "multiply before divide." It is "multiplication and division together, left to right."
Solve: 3 + 4 x 2
Step 1: Multiplication first: 4 x 2 = 8
Step 2: Then addition: 3 + 8 = 11
(Not 14! A common mistake is doing 3 + 4 = 7 first.)
Solve: (3 + 4) x 2
Step 1: Brackets first: 3 + 4 = 7
Step 2: Then multiply: 7 x 2 = 14
Solve: 10 - 3 x 2 + 8 / 4
Step 1: Multiplication: 3 x 2 = 6
Step 2: Division: 8 / 4 = 2
Step 3: Now left to right: 10 - 6 + 2 = 4 + 2 = 6
Solve: 2 + 3^2 x 4
Step 1: Exponent first: 3^2 = 9
Step 2: Multiplication: 9 x 4 = 36
Step 3: Addition: 2 + 36 = 38
Solve: 5 x (6 - 2)^2 + 12 / 3 - 1
Step 1: Brackets: 6 - 2 = 4
Step 2: Exponent: 4^2 = 16
Step 3: Multiplication: 5 x 16 = 80
Step 4: Division: 12 / 3 = 4
Step 5: Left to right: 80 + 4 - 1 = 83
Practice these step-by-step:
1) 2 + 3 x 4^2 - 1
Step 1: Exponent: 4^2 = 16
Step 2: Multiply: 3 x 16 = 48
Step 3: Left to right: 2 + 48 - 1 = 50 - 1 = 49
2) (8 - 3) x 2 + 10 / 5
Step 1: Brackets: 8 - 3 = 5
Step 2: Multiply: 5 x 2 = 10
Step 3: Divide: 10 / 5 = 2
Step 4: Add: 10 + 2 = 12
3) 15 / 3 x 2 - 4
Step 1: Division first (left to right): 15 / 3 = 5
Step 2: Then multiply: 5 x 2 = 10
Step 3: Subtract: 10 - 4 = 6
Remember BODMAS with: "Big Old Dogs Must Always Sleep" or "Please Excuse My Dear Aunt Sally" (PEMDAS). But remember: MD and AS are equal priority, left to right!
Compilers and interpreters follow exactly the same rules. When you write:
The compiler does multiplication first, just like BODMAS says. This is called operator precedence. Every language has a precedence table -- and it matches the math you just learned. If you want addition first, you use parentheses: (3 + 4) * 2 = 14. This is also why complex boolean expressions like a || b && c can surprise you -- && has higher precedence than ||, just like * beats +.
Evaluate each expression. Show every step. Remember: Brackets first, then Exponents, then Multiplication/Division (left to right), then Addition/Subtraction (left to right).
1) 3 + 4 x 2
2) 10 - 2 x 3
3) 8 / 4 + 6
4) 15 - 6 / 2
5) 2 + 3 x 4 - 1
6) 20 / 5 + 3 x 2
7) 7 x 3 - 4 x 2
8) 36 / 6 / 3
9) 5 + 10 / 2 - 3
10) 8 x 2 + 12 / 4 - 5
1) 3 + 8 = 11
2) 10 - 6 = 4
3) 2 + 6 = 8
4) 15 - 3 = 12
5) 2 + 12 - 1 = 13
6) 4 + 6 = 10
7) 21 - 8 = 13
8) 6 / 3 = 2 (left to right)
9) 5 + 5 - 3 = 7
10) 16 + 3 - 5 = 14
1) (3 + 4) x 2
2) 5 x (8 - 3)
3) (12 + 8) / (4 + 1)
4) 3 x (2 + 5) - 4
5) (9 - 3) x (4 + 2)
6) 100 / (4 x 5)
7) (7 + 3) x (10 - 6) / 2
8) 2 x (3 + 4 x 2)
9) ((6 + 2) x 3 - 4) / 5
10) 50 - 3 x (8 + 2) + 4
1) 7 x 2 = 14
2) 5 x 5 = 25
3) 20 / 5 = 4
4) 3 x 7 - 4 = 21 - 4 = 17
5) 6 x 6 = 36
6) 100 / 20 = 5
7) 10 x 4 / 2 = 40 / 2 = 20
8) Inside bracket: 3 + 8 = 11. Then 2 x 11 = 22
9) Inner: 8 x 3 = 24. Then 24 - 4 = 20. Then 20/5 = 4
10) 50 - 3 x 10 + 4 = 50 - 30 + 4 = 24
1) 2^3 + 4
2) 3^2 x 2
3) 5 + 2^4 / 4
4) (2 + 3)^2
5) 2^3 + 3^2
6) 10 - 2^3 + 1
7) (4 + 1)^2 - 3 x 5
8) 3^3 / 9 + 2^2
9) 100 - (2^2 + 3)^2
10) 2^(1+2) x 3 - 4^2
1) 8 + 4 = 12
2) 9 x 2 = 18
3) 5 + 16/4 = 5 + 4 = 9
4) 5^2 = 25
5) 8 + 9 = 17
6) 10 - 8 + 1 = 3
7) 25 - 15 = 10
8) 27/9 + 4 = 3 + 4 = 7
9) 100 - (4+3)^2 = 100 - 49 = 51
10) 2^3 x 3 - 16 = 8 x 3 - 16 = 24 - 16 = 8
A fraction represents a part of a whole. If you cut a pizza into 4 equal slices and eat 1, you have eaten 1/4 of the pizza. The top number (numerator) tells you how many parts you have. The bottom number (denominator) tells you how many equal parts the whole was divided into.
But here's what people often miss: a fraction is also a division. The fraction 3/4 literally means "3 divided by 4." The fraction bar IS a division sign. Once this clicks, fractions stop being scary -- they're just division you haven't done yet.
The denominator (bottom) tells you what SIZE the pieces are. The numerator (top) tells you HOW MANY pieces you have. A bigger denominator means SMALLER pieces (cutting into more slices makes each one thinner). This is why 1/8 is smaller than 1/4 -- eighths are tinier pieces than quarters.
| Type | Definition | Examples |
|---|---|---|
| Proper | Numerator is smaller than denominator (less than 1) | 1/2, 3/4, 7/10 |
| Improper | Numerator is equal to or larger than denominator (1 or more) | 5/3, 9/4, 7/7 |
| Mixed Number | A whole number combined with a proper fraction | 1 2/3, 3 1/4, 2 5/8 |
Convert 7/3 to a mixed number:
Step 1: Divide 7 by 3: 7 / 3 = 2 remainder 1
Step 2: The whole number is 2, the remainder goes over the denominator: 2 1/3
Convert 3 2/5 to an improper fraction:
Step 1: Multiply whole number by denominator: 3 x 5 = 15
Step 2: Add the numerator: 15 + 2 = 17
Step 3: Put over original denominator: 17/5
Equivalent fractions look different but represent the same value. You create them by multiplying (or dividing) the numerator and denominator by the same number.
1/2 = 2/4 = 3/6 = 4/8 = 50/100
All of these equal one half. We multiplied top and bottom by the same number each time.
To simplify a fraction, divide both the numerator and denominator by their Greatest Common Divisor (GCD) -- the largest number that divides both evenly.
Step 1: Find the GCD of 12 and 18. Factors of 12: 1, 2, 3, 4, 6, 12. Factors of 18: 1, 2, 3, 6, 9, 18. GCD = 6.
Step 2: Divide both by 6: 12/6 = 2, 18/6 = 3
Result: 12/18 = 2/3
If you struggle with finding factors, try this: start with the smaller number and work down. Does 12 divide both 12 and 18? No (18/12 = 1.5). Does 6? Yes (12/6 = 2, 18/6 = 3). So 6 is the GCD. Or use trial division: try 2, then 3, then 4, etc.
Simplify these fractions:
1) 6/9: Both divide by 3 → 6/9 = 2/3
2) 15/25: Both divide by 5 → 15/25 = 3/5
3) 8/12: Both divide by 4 → 8/12 = 2/3
4) 10/15: Both divide by 5 → 10/15 = 2/3
Common pattern: Look for numbers both top and bottom can be divided by evenly.
This trips people up, but there are simple methods.
Method 1: Same denominator. If the denominators match, the bigger numerator wins.
Method 2: Same numerator. If the numerators match, the SMALLER denominator wins (bigger pieces).
Method 3: Cross multiply. Works for ANY two fractions. Multiply diagonally and compare.
Cross multiply: 3 × 3 = 9 (left side) vs 2 × 5 = 10 (right side)
10 > 9, so the right fraction wins: 2/3 > 3/5
Check with decimals: 3/5 = 0.6, 2/3 = 0.667 ✓
Cross multiply: 5 × 12 = 60 vs 7 × 8 = 56
60 > 56, so 5/8 > 7/12
When you need to add, subtract, or compare fractions with different denominators, you need a common denominator. The LCD is the smallest number both denominators divide into evenly. Here's how to find it:
Method 1: List multiples (works for small numbers)
Multiples of 4: 4, 8, 12, 16, 20, 24, ...
Multiples of 6: 6, 12, 18, 24, ...
First number in both lists: LCD = 12
Method 2: Check if one divides the other (quickest when it works)
Does 5 divide evenly into 10? Yes! So LCD = 10
This works whenever one denominator is a multiple of the other.
Method 3: Multiply the denominators (always works, might not be smallest)
3 and 7 share no common factors, so LCD = 3 × 7 = 21
When the denominators share no factors, multiplying them IS the LCD.
Ask in this order:
"Of" in math means multiply. So "3/4 of 20" means 3/4 × 20.
Step 1: Divide by denominator: 20 ÷ 4 = 5 (each quarter is 5)
Step 2: Multiply by numerator: 5 × 3 = 15
Check: 3/4 × 20 = 60/4 = 15 ✓
35 ÷ 5 = 7, then 7 × 2 = 14
120 ÷ 8 = 15, then 15 × 5 = 75
Same denominator: Just add the numerators and keep the denominator.
2/7 + 3/7 = ?
Same denominator, so: (2 + 3) / 7 = 5/7
Different denominators: First find the Least Common Denominator (LCD), convert both fractions, then add.
1/3 + 1/4 = ?
Step 1: LCD of 3 and 4 is 12.
Step 2: Convert: 1/3 = 4/12, and 1/4 = 3/12
Step 3: Add: 4/12 + 3/12 = 7/12
2/5 + 3/10 = ?
Step 1: LCD of 5 and 10 is 10.
Step 2: Convert: 2/5 = 4/10 (multiply top and bottom by 2). 3/10 stays the same.
Step 3: Add: 4/10 + 3/10 = 7/10
3/4 + 1/6 = ?
Step 1: LCD of 4 and 6 is 12.
Step 2: Convert: 3/4 = 9/12, and 1/6 = 2/12
Step 3: Add: 9/12 + 2/12 = 11/12
Step 4: Already simplified. Answer: 11/12
Subtraction works the same way as addition -- find a common denominator, then subtract the numerators.
5/6 - 1/3 = ?
Step 1: LCD of 6 and 3 is 6.
Step 2: Convert: 1/3 = 2/6
Step 3: Subtract: 5/6 - 2/6 = 3/6 = 1/2
7/8 - 1/4 = ?
Step 1: LCD of 8 and 4 is 8.
Step 2: Convert: 1/4 = 2/8
Step 3: Subtract: 7/8 - 2/8 = 5/8
3/5 - 1/10 = ?
Step 1: LCD of 5 and 10 is 10.
Step 2: Convert: 3/5 = 6/10
Step 3: Subtract: 6/10 - 1/10 = 5/10 = 1/2
This is actually the easiest operation with fractions. Just multiply straight across: numerator times numerator, denominator times denominator.
2/3 x 4/5 = ?
Multiply across: (2 x 4) / (3 x 5) = 8/15
3/4 x 2/7 = ?
Multiply across: (3 x 2) / (4 x 7) = 6/28 = 3/14
5/6 x 3/10 = ?
Multiply across: (5 x 3) / (6 x 10) = 15/60
Simplify: GCD of 15 and 60 is 15. So 15/60 = 1/4
Before multiplying, you can simplify diagonally. In 5/6 x 3/10: the 5 and 10 share a factor of 5 (giving 1 and 2), and the 3 and 6 share a factor of 3 (giving 1 and 2). So it becomes 1/2 x 1/2 = 1/4. Much easier!
To divide by a fraction, flip the second fraction (swap its numerator and denominator) and then multiply.
3/4 / 2/5 = ?
Step 1: Flip the second fraction: 2/5 becomes 5/2
Step 2: Multiply: 3/4 x 5/2 = 15/8
Step 3: Convert to mixed: 1 7/8
5/6 / 1/3 = ?
Step 1: Flip: 1/3 becomes 3/1
Step 2: Multiply: 5/6 x 3/1 = 15/6
Step 3: Simplify: 15/6 = 5/2 = 2 1/2
7/8 / 7/4 = ?
Step 1: Flip: 7/4 becomes 4/7
Step 2: Multiply: 7/8 x 4/7 = 28/56
Step 3: Simplify: 28/56 = 1/2
Only flip the second fraction (the one you are dividing by). Do NOT flip both. And remember: flipping is also called finding the reciprocal.
Think of division as "how many times does this fit?" For example, 1/2 ÷ 1/4 asks "how many quarters fit in a half?" The answer is 2. Using our rule: 1/2 ÷ 1/4 = 1/2 × 4/1 = 4/2 = 2. It works because division by a fraction is the same as multiplication by its reciprocal.
Recipe scaling: If a recipe calls for 2/3 cup of flour and you want to make half the recipe, calculate 2/3 ÷ 2/1 = 2/3 × 1/2 = 2/6 = 1/3 cup.
Time management: You have 3/4 hour to complete tasks that take 1/6 hour each. How many can you complete? 3/4 ÷ 1/6 = 3/4 × 6/1 = 18/4 = 4.5, so you can complete 4 full tasks.
| From | To | How |
|---|---|---|
| Fraction | Decimal | Divide numerator by denominator: 3/4 = 3 / 4 = 0.75 |
| Decimal | Fraction | Put over a power of 10, simplify: 0.75 = 75/100 = 3/4 |
| Fraction | Percentage | Convert to decimal, then multiply by 100: 3/4 = 0.75 = 75% |
| Percentage | Fraction | Put over 100, simplify: 75% = 75/100 = 3/4 |
| Decimal | Percentage | Multiply by 100: 0.75 x 100 = 75% |
| Percentage | Decimal | Divide by 100: 75% / 100 = 0.75 |
Convert 3/8 to a decimal and a percentage:
Decimal: 3 / 8 = 0.375
Percentage: 0.375 x 100 = 37.5%
Mixed numbers (like 2 3/4) combine a whole number and a fraction. To do arithmetic with them, you usually convert to improper fractions first, do the operation, then convert back.
2 1/3 + 1 3/4 = ?
Step 1: Convert to improper fractions: 2 1/3 = 7/3, 1 3/4 = 7/4
Step 2: Find LCD of 3 and 4 = 12
Step 3: Convert: 7/3 = 28/12, 7/4 = 21/12
Step 4: Add: 28/12 + 21/12 = 49/12
Step 5: Convert back: 49 ÷ 12 = 4 remainder 1 → 4 1/12
5 1/2 - 2 3/4 = ?
Step 1: Convert: 5 1/2 = 11/2, 2 3/4 = 11/4
Step 2: LCD of 2 and 4 = 4
Step 3: Convert: 11/2 = 22/4
Step 4: Subtract: 22/4 - 11/4 = 11/4
Step 5: Convert back: 11 ÷ 4 = 2 remainder 3 → 2 3/4
1 2/3 × 2 1/5 = ?
Step 1: Convert: 1 2/3 = 5/3, 2 1/5 = 11/5
Step 2: Multiply across: (5 × 11) / (3 × 5) = 55/15
Step 3: Simplify: GCD of 55 and 15 is 5 → 11/3
Step 4: Convert back: 11 ÷ 3 = 3 remainder 2 → 3 2/3
3 1/2 ÷ 1 1/4 = ?
Step 1: Convert: 3 1/2 = 7/2, 1 1/4 = 5/4
Step 2: Flip and multiply: 7/2 × 4/5 = 28/10
Step 3: Simplify: 28/10 = 14/5
Step 4: Convert back: 14 ÷ 5 = 2 remainder 4 → 2 4/5
For addition only, you can sometimes add the whole numbers and fractions separately. 2 1/3 + 1 1/3 = (2 + 1) + (1/3 + 1/3) = 3 2/3. But be careful -- if the fraction parts add up to more than 1, you need to carry. 2 3/4 + 1 1/2 = 3 + (3/4 + 2/4) = 3 + 5/4 = 3 + 1 1/4 = 4 1/4.
A complex fraction has a fraction in the numerator, denominator, or both. They look scary but are just division problems in disguise.
Simplify: (3/4) / (5/8)
This means 3/4 ÷ 5/8
Flip and multiply: 3/4 × 8/5 = 24/20 = 6/5 = 1 1/5
Simplify: (2/3) / 4
This means 2/3 ÷ 4/1
Flip and multiply: 2/3 × 1/4 = 2/12 = 1/6
Simplify: 6 / (3/5)
This means 6/1 ÷ 3/5
Flip and multiply: 6/1 × 5/3 = 30/3 = 10
Simplify: (1/2 + 1/3) / (1/4)
Step 1: Simplify the numerator first: 1/2 + 1/3 = 3/6 + 2/6 = 5/6
Step 2: Now divide: 5/6 ÷ 1/4 = 5/6 × 4/1 = 20/6 = 10/3 = 3 1/3
Always ask: "What is being divided by what?" The main fraction bar (the longest one) separates the top from the bottom. Everything above it is the numerator, everything below is the denominator. Then it is just a division problem.
BODMAS/PEMDAS applies to fractions just as it does to whole numbers. Work through brackets first, then exponents, then multiplication/division (left to right), then addition/subtraction (left to right).
Evaluate: 1/2 + 1/3 × 3/4
Step 1: Multiplication first: 1/3 × 3/4 = 3/12 = 1/4
Step 2: Then addition: 1/2 + 1/4 = 2/4 + 1/4 = 3/4
Evaluate: (2/3 + 1/6) × 3/5
Step 1: Brackets first: 2/3 + 1/6 = 4/6 + 1/6 = 5/6
Step 2: Then multiply: 5/6 × 3/5 = 15/30 = 1/2
Evaluate: 3/4 - 1/2 × 1/3 + 1/6
Step 1: Multiplication first: 1/2 × 1/3 = 1/6
Step 2: Left to right: 3/4 - 1/6 + 1/6
Step 3: LCD of 4 and 6 is 12: 9/12 - 2/12 + 2/12 = 9/12 = 3/4
Evaluate: (2/3)^2 + 1/9
Step 1: Exponent first: (2/3)^2 = 4/9
Step 2: Add: 4/9 + 1/9 = 5/9
Do NOT add before multiplying! In 1/2 + 1/3 × 3/4, many people add 1/2 + 1/3 first and get 5/6, then multiply by 3/4 to get 15/24 = 5/8. Wrong! Multiplication comes before addition. The correct answer is 3/4. Order of operations never takes a holiday.
Math notation can look ambiguous. It's not -- there are exact rules for how to read every expression. If your brain freezes when you see something like -4/2 or 40 + n³/2, this section gives you the precise rules so you never have to guess.
In programming, x = 5 + 3 * 2 evaluates to 11, not 16, because of operator precedence. Math notation works the same way -- there are parsing rules. Learn them once, and ambiguity disappears forever.
When you see a negative sign with a fraction, here's the exact rule:
| Expression | Meaning | Result | Why |
|---|---|---|---|
| -4/2 | (-4) ÷ 2 | -2 | Negative ÷ positive = negative |
| 4/(-2) | 4 ÷ (-2) | -2 | Positive ÷ negative = negative |
| -4/(-2) | (-4) ÷ (-2) | +2 | Negative ÷ negative = positive |
| -6/3 | (-6) ÷ 3 | -2 | Negative ÷ positive = negative |
| 6/(-3) | 6 ÷ (-3) | -2 | Positive ÷ negative = negative |
| -6/(-3) | (-6) ÷ (-3) | +2 | Negative ÷ negative = positive |
-3² = -(3²) = -9 (the negative is NOT inside the exponent)
(-3)² = (-3) × (-3) = +9 (the negative IS part of the base)
Without parentheses, the exponent binds tighter than the negative sign. This is just like how in code -3**2 gives -9 in Python.
A fraction bar acts as a grouping symbol. Everything above the bar is one group. Everything below is another group. This is like having parentheses around both the numerator and denominator.
These look similar but are completely different:
| Written as | Means | Result (with a=10, b=6, c=2) |
|---|---|---|
| (a + b) / c | (10 + 6) ÷ 2 | 8 |
| a + b / c | 10 + (6 ÷ 2) | 13 |
When you see 40 + n³/2 written inline, it means 40 + (n³ ÷ 2), not (40 + n³) ÷ 2.
If the author means the whole thing divided by 2, they must write (40 + n³) / 2 with parentheses.
This is where most people get confused. There's one rule:
(40 + n³) / 2 = 40/2 + n³/2 = 20 + n³/2 ✓
Think of it like distributing division: you're dividing each piece by 2.
Verify: (40 + 8)/2 = 48/2 = 24. And 40/2 + 8/2 = 20 + 4 = 24. Same! ✓
12 / (3 + 1) ≠ 12/3 + 12/1
Left side: 12/4 = 3
Right side: 4 + 12 = 16
3 ≠ 16. Completely wrong! You cannot split the denominator.
Students constantly do this: 1/(a + b) = 1/a + 1/b. This is WRONG.
Quick proof: 1/(2 + 3) = 1/5 = 0.2. But 1/2 + 1/3 = 5/6 ≈ 0.833. Not even close.
Remember: split numerators, NEVER split denominators.
Any whole number can be written as a fraction with denominator 1:
20 + x/2 = ? (make a single fraction)
Step 1: Write 20 as a fraction: 20/1
Step 2: Common denominator is 2: 20/1 = 40/2
Step 3: Now add: 40/2 + x/2 = (40 + x)/2
3n × n³/2 = ?
Step 1: 3n = 3n/1 (write as fraction)
Step 2: Multiply fractions: (3n/1) × (n³/2) = 3n × n³ / (1 × 2) = 3n4/2
Or just think: 3n × n³ = 3n4, then divide by 2 = 3n4/2
| You See | It Means | Rule |
|---|---|---|
| -a/b | (-a) ÷ b = negative | Negative sticks to what's next to it |
| a + b/c | a + (b ÷ c) | Division before addition (BODMAS) |
| (a + b)/c | (a + b) ÷ c | Parentheses override everything |
| -x² | -(x²) | Exponent binds tighter than negative |
| (-x)² | (-x) × (-x) = x² | Parentheses make negative part of base |
| a × b/c | (a × b) ÷ c | Left to right for same-precedence ops |
| (a + b)/c | a/c + b/c | Can split numerator |
| c/(a + b) | Cannot split! | Cannot split denominator |
Math notation follows the exact same precedence rules as programming languages:
If you can read -3**2 + 4*5/2 in Python (answer: -9 + 10 = 1), you can read any math expression. The rules are identical.
Word problems are where fractions really click. The key: read carefully, identify which operation to use, and translate words into math.
A rope is 12 metres long. You cut off 2/3 of it. How long is the piece you cut?
"Of" means multiply: 2/3 × 12 = 24/3 = 8 metres
The remaining piece: 12 - 8 = 4 metres (which is 1/3 of 12 ✓)
You have read 3/5 of a 250-page book. How many pages are left?
Pages read: 3/5 × 250 = 750/5 = 150
Pages left: 250 - 150 = 100 pages
Or: fraction left = 1 - 3/5 = 2/5, and 2/5 × 250 = 100 ✓
A tank is 1/3 full. You add water until it is 3/4 full. What fraction of the tank did you fill?
Water added: 3/4 - 1/3 = 9/12 - 4/12 = 5/12 of the tank
A machine produces 3/4 of a widget per minute. How many minutes to produce 6 widgets?
Minutes = 6 ÷ 3/4 = 6 × 4/3 = 24/3 = 8 minutes
A class has 40 students. 1/4 wear glasses. Of those who wear glasses, 2/5 also wear hats. How many students wear both glasses and hats?
Step 1: Students with glasses: 1/4 × 40 = 10
Step 2: Of those, with hats: 2/5 × 10 = 4 students
Or in one step: 1/4 × 2/5 × 40 = 2/20 × 40 = 80/20 = 4 ✓
Computers don't store fractions as "1/3" -- they convert them to decimals (floating-point). This means some fractions lose precision. The classic example: 1/3 = 0.33333... gets cut off. This is why financial software never uses float for money -- they use integers (cents) or special decimal types. When you see a bug where $10.00 becomes $9.99, now you know why.
In algorithms, fractions show up constantly: probability calculations, hash table load factors (items / buckets), and dividing work across threads.
Grab a pencil and paper. Do not look at the answers until you've tried each problem yourself. Write out every step. If you get stuck, re-read the relevant section above, then try again before checking.
1) 8/12
2) 15/20
3) 24/36
4) 14/49
5) 18/27
6) 42/56
7) 30/75
8) 48/64
9) 63/81
10) 90/120
1) 8/12 = 2/3 (GCD = 4)
2) 15/20 = 3/4 (GCD = 5)
3) 24/36 = 2/3 (GCD = 12)
4) 14/49 = 2/7 (GCD = 7)
5) 18/27 = 2/3 (GCD = 9)
6) 42/56 = 3/4 (GCD = 14)
7) 30/75 = 2/5 (GCD = 15)
8) 48/64 = 3/4 (GCD = 16)
9) 63/81 = 7/9 (GCD = 9)
10) 90/120 = 3/4 (GCD = 30)
1) 3/7 or 2/5
2) 5/8 or 3/5
3) 4/9 or 5/11
4) 7/12 or 5/8
5) 2/3 or 5/8
6) 11/15 or 7/10
7) 3/11 or 2/7
8) 9/14 or 5/8
1) 3/7 > 2/5 (cross: 15 > 14)
2) 5/8 > 3/5 (cross: 25 > 24)
3) 5/11 > 4/9 (cross: 45 > 44)
4) 5/8 > 7/12 (cross: 60 > 56)
5) 2/3 > 5/8 (cross: 16 > 15)
6) 11/15 > 7/10 (cross: 110 > 105)
7) 3/11 > 2/7 (cross: 21 > 22... wait: 21 < 22, so 2/7 > 3/11. Trick question -- be careful!)
8) 9/14 > 5/8 (cross: 72 > 70)
1) 1/4 + 2/4
2) 3/5 + 1/10
3) 2/3 + 3/8
4) 5/6 + 7/12
5) 1/2 + 2/5 + 1/10
6) 7/8 - 1/4
7) 5/6 - 2/9
8) 11/12 - 3/8
9) 3/4 - 1/3 + 1/6
10) 7/10 - 1/5 + 3/20
1) 1/4 + 2/4 = 3/4
2) 3/5 + 1/10 = 6/10 + 1/10 = 7/10
3) 2/3 + 3/8 = 16/24 + 9/24 = 25/24 = 1 1/24
4) 5/6 + 7/12 = 10/12 + 7/12 = 17/12 = 1 5/12
5) 1/2 + 2/5 + 1/10 = 5/10 + 4/10 + 1/10 = 10/10 = 1
6) 7/8 - 1/4 = 7/8 - 2/8 = 5/8
7) 5/6 - 2/9 = 15/18 - 4/18 = 11/18
8) 11/12 - 3/8 = 22/24 - 9/24 = 13/24
9) 3/4 - 1/3 + 1/6 = 9/12 - 4/12 + 2/12 = 7/12
10) 7/10 - 1/5 + 3/20 = 14/20 - 4/20 + 3/20 = 13/20
1) 2/3 x 3/4
2) 5/7 x 14/15
3) 4/9 x 3/8
4) 7/10 x 5/21
5) 3/4 x 2/5 x 10/9
6) 3/5 / 2/3
7) 7/8 / 7/4
8) 5/12 / 10/3
9) 9/16 / 3/8
10) 2/3 / 4/9 x 1/2
1) 2/3 x 3/4 = 6/12 = 1/2
2) 5/7 x 14/15 = 70/105 = 2/3
3) 4/9 x 3/8 = 12/72 = 1/6
4) 7/10 x 5/21 = 35/210 = 1/6
5) 3/4 x 2/5 x 10/9 = 60/180 = 1/3
6) 3/5 / 2/3 = 3/5 x 3/2 = 9/10 = 9/10
7) 7/8 / 7/4 = 7/8 x 4/7 = 28/56 = 1/2
8) 5/12 / 10/3 = 5/12 x 3/10 = 15/120 = 1/8
9) 9/16 / 3/8 = 9/16 x 8/3 = 72/48 = 3/2 = 1 1/2
10) 2/3 / 4/9 x 1/2 = 2/3 x 9/4 x 1/2 = 18/24 = 3/4
1) Convert 17/5 to a mixed number
2) Convert 4 2/3 to an improper fraction
3) 2 1/4 + 1 2/3
4) 3 1/2 - 1 3/4
5) 1 2/5 x 2 1/3
6) 4 1/2 / 1 1/2
7) 5 2/3 + 2 3/4 - 1 1/6
8) 3 1/8 x 2 2/5
1) 17/5 = 3 2/5
2) 4 2/3 = 14/3
3) 9/4 + 5/3 = 27/12 + 20/12 = 47/12 = 3 11/12
4) 7/2 - 7/4 = 14/4 - 7/4 = 7/4 = 1 3/4
5) 7/5 x 7/3 = 49/15 = 3 4/15
6) 9/2 / 3/2 = 9/2 x 2/3 = 18/6 = 3
7) 17/3 + 11/4 - 7/6 = 68/12 + 33/12 - 14/12 = 87/12 = 29/4 = 7 1/4
8) 25/8 x 12/5 = 300/40 = 15/2 = 7 1/2
1) (2/3) / (4/5)
2) (1/2 + 1/4) / (3/8)
3) 1/3 + 2/5 x 5/6
4) (3/4 - 1/2) x 8/3
5) (2/3)^2 + 1/3
6) 1/2 x 3/4 + 1/8 / 1/2
7) 6 / (2/7)
8) (1/2 + 1/3) / (1/2 - 1/3)
1) 2/3 x 5/4 = 10/12 = 5/6
2) (2/4 + 1/4) / (3/8) = (3/4) / (3/8) = 3/4 x 8/3 = 24/12 = 2
3) Multiply first: 2/5 x 5/6 = 10/30 = 1/3. Then add: 1/3 + 1/3 = 2/3
4) Brackets first: 3/4 - 2/4 = 1/4. Then: 1/4 x 8/3 = 8/12 = 2/3
5) Exponent first: 4/9. Then: 4/9 + 3/9 = 7/9
6) Left to right for x and /: 1/2 x 3/4 = 3/8, then 1/8 / 1/2 = 1/8 x 2/1 = 2/8 = 1/4. Then add: 3/8 + 1/4 = 3/8 + 2/8 = 5/8
7) 6/1 x 7/2 = 42/2 = 21
8) Top: 3/6 + 2/6 = 5/6. Bottom: 3/6 - 2/6 = 1/6. Then: 5/6 / 1/6 = 5/6 x 6/1 = 5
1) A pizza is cut into 8 slices. You eat 3 slices and your friend eats 2. What fraction of the pizza is left?
2) A recipe needs 2/3 cup of sugar. You want to make 1 1/2 batches. How much sugar do you need?
3) A tank is 7/8 full. After using some water, it is 1/3 full. What fraction of the tank was used?
4) You have 60 marbles. 2/5 are red, 1/4 are blue, and the rest are green. How many green marbles are there?
5) A worker can build 3/4 of a wall in one day. How many days will it take to build 6 walls?
6) A school has 480 students. 3/8 of them walk to school, 1/4 take the bus, and the rest get driven. How many students get driven?
7) A rope is 15 metres long. You cut off 2/5 of it, then cut 1/3 off the remaining piece. How long is the rope now?
8) Three friends split a bill. Alex pays 1/3, Ben pays 2/5, and Charlie pays the rest. If the bill is $120, how much does each person pay?
9) A jar is 1/6 full of water. You pour in enough to make it 3/4 full. What fraction of the jar did you fill?
10) A car uses 1/12 of its fuel tank per hour on the motorway. The tank is 3/4 full. How many hours can the car drive before the tank is empty?
1) Eaten: 3/8 + 2/8 = 5/8. Left: 1 - 5/8 = 3/8
2) 2/3 x 3/2 = 6/6 = 1 cup
3) 7/8 - 1/3 = 21/24 - 8/24 = 13/24
4) Red: 2/5 x 60 = 24. Blue: 1/4 x 60 = 15. Green: 60 - 24 - 15 = 21 marbles
5) Days = 6 / (3/4) = 6 x 4/3 = 24/3 = 8 days
6) Walk: 3/8 x 480 = 180. Bus: 1/4 x 480 = 120. Driven: 480 - 180 - 120 = 180 students
7) After first cut: 15 - (2/5 x 15) = 15 - 6 = 9m. After second cut: 9 - (1/3 x 9) = 9 - 3 = 6 metres
8) Alex: 1/3 x 120 = $40. Ben: 2/5 x 120 = $48. Charlie: 120 - 40 - 48 = $32 (or 4/15 of $120)
9) 3/4 - 1/6 = 9/12 - 2/12 = 7/12
10) 3/4 / (1/12) = 3/4 x 12/1 = 36/4 = 9 hours
1) If 2/3 of a number is 48, what is 5/8 of that number?
2) A box contains red, blue, and green balls. 1/3 are red, 3/8 are blue. If there are 24 green balls, how many balls are in the box?
3) After spending 1/4 of his money on books and 2/5 of the remainder on food, Tom had $36 left. How much did he start with?
4) Pipe A fills a tank in 6 hours. Pipe B fills the same tank in 4 hours. If both pipes are open together, how long to fill the tank?
5) Simplify: (1/2 + 1/3 + 1/6) / (1/2 - 1/3 + 1/6)
1) 2/3 of x = 48, so x = 48 x 3/2 = 72. Then 5/8 of 72 = 5/8 x 72 = 360/8 = 45
2) Green fraction = 1 - 1/3 - 3/8 = 24/24 - 8/24 - 9/24 = 7/24. So 7/24 of total = 24. Total = 24 x 24/7 = 576/7... Hmm, let's recheck: 1/3 + 3/8 = 8/24 + 9/24 = 17/24. Green = 7/24 of total = 24 balls. Total = 24 x 24/7. That's not a whole number -- so let's interpret: total must be divisible by both 3 and 8, i.e. 24. If total = 24: Red = 8, Blue = 9, Green = 7. But we said 24 green? Total = 24 x (24/7) doesn't work cleanly. Re-read: green = 24 balls = 7/24 of total. Total = 24 / (7/24) = 24 x 24/7. Not whole. The problem needs adjustment -- answer is approximately 82 balls (rounded). In a real test this fraction would be chosen to divide evenly.
3) After books: 3/4 remains. After food: spends 2/5 of 3/4 = 6/20 = 3/10. Left = 3/4 - 3/10 = 15/20 - 6/20 = 9/20. So 9/20 of original = $36. Original = 36 x 20/9 = $80
4) Pipe A rate: 1/6 tank per hour. Pipe B rate: 1/4 tank per hour. Combined: 1/6 + 1/4 = 2/12 + 3/12 = 5/12 per hour. Time = 1 / (5/12) = 12/5 = 2 2/5 hours (2 hours 24 minutes)
5) Top: 3/6 + 2/6 + 1/6 = 6/6 = 1. Bottom: 3/6 - 2/6 + 1/6 = 2/6 = 1/3. Answer: 1 / (1/3) = 3
You've done the problems on this page. Now go practice on these sites to build real strength:
Decimals are another way to write fractions, using a decimal point instead of a fraction bar. They are based on powers of 10.
Each position after the decimal point has a specific name and value:
| Position | Name | Value | Example in 3.456 |
|---|---|---|---|
| 1st after decimal | Tenths | 1/10 = 0.1 | 4 (four tenths) |
| 2nd after decimal | Hundredths | 1/100 = 0.01 | 5 (five hundredths) |
| 3rd after decimal | Thousandths | 1/1000 = 0.001 | 6 (six thousandths) |
3.456 is read as "three and four hundred fifty-six thousandths." The number of decimal places tells you the denominator: 1 place = tenths, 2 places = hundredths, 3 places = thousandths, and so on.
The key rule: line up the decimal points, then add or subtract as normal. Fill empty spots with zeros.
3.25 + 1.7 = ?
Line up:
3.25
+ 1.70
------
4.95
Answer: 4.95
5.03 - 2.8 = ?
Line up:
5.03
- 2.80
------
2.23
Answer: 2.23
Multiply the numbers as if there were no decimals. Then count the total decimal places in both original numbers and put that many decimal places in the answer.
2.5 x 1.3 = ?
Step 1: Multiply as whole numbers: 25 x 13 = 325
Step 2: Count decimal places: 2.5 has 1, 1.3 has 1, total = 2
Step 3: Place decimal: 325 becomes 3.25
Answer: 3.25
0.4 x 0.03 = ?
Step 1: 4 x 3 = 12
Step 2: Decimal places: 1 + 2 = 3
Step 3: Place decimal: 12 becomes 0.012
Answer: 0.012
If the divisor (the number you are dividing by) has a decimal, move the decimal point to the right until it is a whole number. Move the decimal in the dividend (the number being divided) the same number of places. Then divide as normal.
6.5 / 0.5 = ?
Step 1: Move decimal 1 place right in both: 65 / 5
Step 2: Divide: 65 / 5 = 13
4.56 / 0.12 = ?
Step 1: Move decimal 2 places right in both: 456 / 12
Step 2: Divide: 456 / 12 = 38
To round a decimal, look at the digit one place to the right of where you want to round. If it is 5 or more, round up. If it is less than 5, round down (keep it the same).
0.6 = ?
0.6 = 6/10 = 3/5 (divide both by 2)
0.125 = ?
0.125 = 125/1000 = 1/8 (divide both by 125)
2.75 = ?
2.75 = 275/100 = 11/4 = 2 3/4
Let's deep dive into each operation with multiple examples to build your confidence.
1.25 + 3.7 + 0.125 = ?
1.250
3.700
+ 0.125
-------
5.075
Key: Add zeros to make all numbers have the same decimal places, then add normally.
5.02 - 2.78 = ?
5.02
- 2.78
------
2.24
Step-by-step: Hundredths: 2 - 8 (can't do, borrow from tenths). Now it's 12 - 8 = 4. Tenths: 9 - 7 = 2 (was 0, became 9 after borrowing, then borrowed to 9). Units: 4 - 2 = 2.
0.25 × 0.04 = ?
Step 1: Multiply as whole numbers: 25 × 4 = 100
Step 2: Count total decimal places: 0.25 has 2, 0.04 has 2, total = 4
Step 3: Place decimal 4 places from the right: 100 → 0.0100 = 0.01
Multiplying by 10, 100, 1000... just moves the decimal right!
3.456 × 10 = 34.56 (move right 1 place)
3.456 × 100 = 345.6 (move right 2 places)
3.456 × 1000 = 3456 (move right 3 places)
Dividing by 10, 100, 1000... moves the decimal left!
345.6 ÷ 10 = 34.56
345.6 ÷ 100 = 3.456
345.6 ÷ 1000 = 0.3456
7 ÷ 4 = ?
Step 1: 7 ÷ 4 = 1 remainder 3
Step 2: Add decimal point and zeros: 7.00
Step 3: Bring down: 30 ÷ 4 = 7 remainder 2
Step 4: Bring down: 20 ÷ 4 = 5
Answer: 1.75
Some fractions create decimals that repeat forever:
When you divide and keep getting remainders that repeat, you have a repeating decimal. We write these with a bar over the repeating digits: 1/3 = 0.3̄ or 1/7 = 0.142857̄
This is one of the most important things to understand as a programmer. Open any browser console and type 0.1 + 0.2. You get 0.30000000000000004. Why? Because computers store decimals in binary floating-point (base 2), and just like 1/3 = 0.333... in base 10, the number 0.1 is a repeating decimal in base 2. It can never be stored exactly.
Practical rule: Never compare floats with ==. Instead, check if the difference is tiny: abs(a - b) < 0.0001. This comes up in game physics, financial calculations, and scientific computing.
Pencil and paper. Line up your decimal points. Show every step.
1) 3.4 + 2.7
2) 12.56 + 3.8
3) 0.125 + 0.875
4) 45.003 + 2.97
5) 100.5 + 0.55 + 9.95
6) 8.5 - 3.2
7) 10.0 - 4.73
8) 25.04 - 8.567
9) 100 - 37.85
10) 6.1 - 2.345
1) 6.1
2) 16.36
3) 1.000 = 1
4) 47.973
5) 111.00 = 111
6) 5.3
7) 5.27
8) 16.473
9) 62.15
10) 3.755
1) 2.5 x 4
2) 0.6 x 0.3
3) 1.2 x 1.5
4) 0.04 x 0.5
5) 3.14 x 10
6) 0.25 x 0.4
7) 7.5 x 0.8
8) 2.5 x 2.5
9) 0.001 x 1000
10) 4.2 x 0.15
1) 10.0 = 10
2) 0.18
3) 1.80 = 1.8
4) 0.020 = 0.02
5) 31.4
6) 0.100 = 0.1
7) 6.00 = 6
8) 6.25
9) 1.000 = 1
10) 0.630 = 0.63
1) 8.4 / 2
2) 6.5 / 0.5
3) 9.6 / 0.4
4) 1.44 / 1.2
5) 0.36 / 0.06
6) 100 / 0.25
7) 7.5 / 2.5
8) 0.84 / 0.12
9) 3.6 / 0.009
10) 15.6 / 1.3
1) 4.2
2) 13
3) 24
4) 1.2
5) 6
6) 400
7) 3
8) 7
9) 400
10) 12
1) Convert 0.375 to a fraction
2) Convert 0.8 to a fraction
3) Convert 3/8 to a decimal
4) Convert 5/6 to a decimal (round to 3 places)
5) Round 3.456 to 1 decimal place
6) Round 12.995 to 2 decimal places
7) Round 0.04449 to 3 decimal places
8) Convert 2.35 to a fraction
9) Is 0.121212... rational or irrational?
10) Express 7/11 as a decimal. Does it terminate or repeat?
1) 375/1000 = 3/8
2) 8/10 = 4/5
3) 0.375
4) 0.833
5) 3.5
6) 13.00 (the 5 rounds up the 9, which cascades)
7) 0.044 (the 4 after doesn't round up)
8) 235/100 = 47/20 = 2 7/20
9) Rational (it repeats, so it can be written as 12/99 = 4/33)
10) 7/11 = 0.636363... (repeating). All fractions either terminate or repeat.
The word "percent" literally means "per hundred" (per centum in Latin). So 25% means 25 out of 100, or 25/100, or 0.25. Percentages are everywhere in daily life -- discounts, grades, statistics, taxes, tips.
| Fraction | Decimal | Percentage |
|---|---|---|
| 1/2 | 0.5 | 50% |
| 1/4 | 0.25 | 25% |
| 3/4 | 0.75 | 75% |
| 1/5 | 0.2 | 20% |
| 1/3 | 0.333... | 33.3% |
| 1/8 | 0.125 | 12.5% |
| 1/10 | 0.1 | 10% |
To find X% of a number, convert the percentage to a decimal and multiply.
What is 20% of 150?
20% = 0.20
0.20 x 150 = 30
What is 15% of 80?
15% = 0.15
0.15 x 80 = 12
What is 7.5% of 200?
7.5% = 0.075
0.075 x 200 = 15
A shirt costs $40 and the price increases by 25%. What is the new price?
Increase amount: 25% of $40 = 0.25 x 40 = $10
New price: $40 + $10 = $50
Or directly: $40 x 1.25 = $50
A laptop costs $800 and is on sale for 15% off. What is the sale price?
Discount amount: 15% of $800 = 0.15 x 800 = $120
Sale price: $800 - $120 = $680
Or directly: $800 x 0.85 = $680
You scored 42 out of 60 on a test. What percentage is that?
(42 / 60) x 100 = 0.7 x 100 = 70%
A class has 30 students. 12 are wearing hats. What percentage?
(12 / 30) x 100 = 0.4 x 100 = 40%
You buy a $45 item and tax is 8%. What is the total?
Tax amount: 0.08 x $45 = $3.60
Total: $45 + $3.60 = $48.60
Your meal costs $32. You want to leave a 20% tip. How much?
Tip: 0.20 x $32 = $6.40
Total bill: $32 + $6.40 = $38.40
Shoes are $120 with a 30% discount, plus 9% tax on the sale price. Final cost?
Discount: 0.30 x $120 = $36
Sale price: $120 - $36 = $84
Tax: 0.09 x $84 = $7.56
Final cost: $84 + $7.56 = $91.56
To find 10% of any number, just move the decimal point one place to the left. 10% of $85 = $8.50. Then you can build from there: 20% = double the 10%, 5% = half the 10%, 15% = 10% + 5%.
Find 35% of 240 using 10% as your base:
10% of 240 = 24 (move decimal left)
30% = 3 × 24 = 72
5% = 24 ÷ 2 = 12
35% = 30% + 5% = 72 + 12 = 84
Find 7% of 350:
1% of 350 = 3.5 (move decimal two places left)
7% = 7 × 3.5 = 24.5
Find 23% of 150:
1% of 150 = 1.5
20% = 20 × 1.5 = 30
3% = 3 × 1.5 = 4.5
23% = 30 + 4.5 = 34.5
If something costs $68 after a 15% discount, what was the original price?
$68 represents 85% of the original (100% - 15% = 85%)
85% = 0.85, so Original × 0.85 = $68
Original = $68 ÷ 0.85 = $80
Check: 15% of $80 = $12, so $80 - $12 = $68 ✓
Interest rates rise from 2% to 3%:
• The rate increased by 1 percentage point (3 - 2 = 1)
• The rate increased by 50% (1/2 = 0.5 = 50%)
Be careful with financial news and statistics – these are very different!
Quick tip calculation: For 15%, find 10% and add half of that. For 20%, just double the 10%. For 18%, it's 10% + 8% (where 8% = 10% - 2%).
Example: Bill is $42. 10% = $4.20. So 15% = $4.20 + $2.10 = $6.30, and 20% = $8.40.
When multiple percentage changes happen one after another, you cannot just add or subtract the percentages. Each change applies to the NEW value, not the original.
A stock is worth $100. It rises 10% one year, then 20% the next. What is it worth now?
After Year 1: $100 × 1.10 = $110
After Year 2: $110 × 1.20 = $132
Note: 10% + 20% = 30%, but $100 × 1.30 = $130 (not $132!). The extra $2 comes from earning 20% on the $10 gain from Year 1.
A shirt costs $80. The price goes up 25%, then there is a 25% off sale. What is the final price?
After increase: $80 × 1.25 = $100
After decrease: $100 × 0.75 = $75
This is NOT back to $80! A 25% increase followed by a 25% decrease gives a net loss of 6.25%. The decrease applies to the larger value.
A population of 10,000 grows by 5% each year for 3 years. What is it after 3 years?
Year 1: 10,000 × 1.05 = 10,500
Year 2: 10,500 × 1.05 = 11,025
Year 3: 11,025 × 1.05 = 11,576.25
Or directly: 10,000 × (1.05)^3 = 10,000 × 1.157625 = 11,576.25
A 50% decrease followed by a 50% increase does NOT get you back to the start. Example: $100 → 50% off → $50 → 50% increase → $75. You lost 25%! To recover from a 50% loss, you need a 100% gain (you need to double). This is why percentage losses in investing hurt more than gains of the same size help.
Percentage error measures how far off an estimate or measurement is from the true value. It is used in science, engineering, and everyday estimation.
You estimated a room to be 5 metres long. It actually measured 4.8 metres. What is the percentage error?
Error = |5 - 4.8| / 4.8 × 100 = 0.2 / 4.8 × 100 = 4.17%
A weather forecast predicted 30mm of rain. The actual rainfall was 25mm. What is the percentage error?
Error = |30 - 25| / 25 × 100 = 5 / 25 × 100 = 20%
Your algorithm estimated 1,200 users would visit the site. The actual count was 1,350. What is the percentage error?
Error = |1200 - 1350| / 1350 × 100 = 150 / 1350 × 100 = 11.11%
The |absolute value| bars mean you always get a positive result, whether your estimate was too high or too low. Some contexts use signed error (positive = overestimate, negative = underestimate) to show direction, but percentage error itself is always positive.
Interest is the cost of borrowing money (or the reward for saving it). Understanding the difference between simple and compound interest is one of the most practical maths skills you will ever learn.
With simple interest, you earn (or pay) interest only on the original amount (the principal). The interest is the same every period.
You invest $1,000 at 5% simple interest per year for 3 years. How much do you have?
Interest per year: $1,000 × 0.05 = $50
Total interest over 3 years: $50 × 3 = $150
Total amount: $1,000 + $150 = $1,150
With compound interest, you earn interest on the principal plus all previously earned interest. Your money grows on top of its own growth -- this is exponential growth, and it is incredibly powerful over time.
You invest $1,000 at 5% compound interest per year for 3 years.
Year 1: $1,000 × 1.05 = $1,050.00
Year 2: $1,050 × 1.05 = $1,102.50
Year 3: $1,102.50 × 1.05 = $1,157.63
Or directly: $1,000 × (1.05)^3 = $1,000 × 1.157625 = $1,157.63
Compare: Simple interest gave $1,150. Compound interest gives $1,157.63. The difference grows dramatically over time.
Want to know how long it takes to double your money? Divide 72 by the interest rate.
At 6%: 72 ÷ 6 = 12 years to double
At 8%: 72 ÷ 8 = 9 years to double
At 12%: 72 ÷ 12 = 6 years to double
This is an approximation, but it is remarkably accurate and useful for quick mental maths.
You owe $5,000 on a credit card at 20% annual interest, compounded monthly. If you make no payments, what do you owe after 1 year?
Monthly rate: 20% / 12 = 1.667% = 0.01667
After 12 months: $5,000 × (1.01667)^12 = $5,000 × 1.2194 = $6,097
That's $1,097 in interest -- more than 20% of the original because it compounds monthly!
Compound interest is either your best friend (savings, investments) or your worst enemy (debt, loans). Einstein allegedly called it "the eighth wonder of the world." Whether or not he actually said it, the point stands: start saving early, because time is the most powerful variable in the formula. $1,000 invested at age 20 at 7% becomes $14,974 by age 60. The same $1,000 invested at age 40 only becomes $3,870.
A laptop costs $1,200. There is a 20% discount, and then 10% sales tax is applied to the discounted price. What do you pay?
Step 1: Discount: $1,200 × 0.80 = $960
Step 2: Tax: $960 × 1.10 = $1,056
Note: This is NOT the same as 10% net discount (which would give $1,080). Order matters because tax applies to the discounted price.
After a 30% increase, a salary is $65,000. What was the original salary?
$65,000 represents 130% of the original
Original = $65,000 ÷ 1.30 = $50,000
Check: $50,000 × 1.30 = $65,000 ✓
A website had 8,500 visitors last month and 10,200 this month. What is the percentage increase?
Change = 10,200 - 8,500 = 1,700
Percentage change = (1,700 / 8,500) × 100 = 20%
A shop buys items for $25 each and sells them for $40. What is the profit margin as a percentage of the selling price?
Profit = $40 - $25 = $15
Profit margin = ($15 / $40) × 100 = 37.5%
(Note: Markup is different -- that's profit as a % of cost: $15/$25 = 60%)
In a school of 600 students, 45% are boys. Of the boys, 2/3 play a sport. Of those, 40% play football. How many boys play football?
Step 1: Boys = 45% of 600 = 0.45 × 600 = 270
Step 2: Boys who play sport = 2/3 × 270 = 180
Step 3: Boys who play football = 40% of 180 = 0.40 × 180 = 72 boys
These three question types cover almost every percentage problem you will ever see.
As a developer, you'll calculate percentages constantly:
(completed / total) * 100 -- loading screens, file uploads, installation progressSame rules as before: pencil, paper, try before you peek. If you get it wrong, figure out WHERE you went wrong -- that's where the real learning happens.
1) 25% of 80
2) 15% of 200
3) 40% of 350
4) 8% of 75
5) 12.5% of 240
6) 2.5% of 1,000
7) 33 1/3% of 126
8) 175% of 60
9) 0.5% of 8,000
10) 66 2/3% of 54
1) 0.25 x 80 = 20
2) 0.15 x 200 = 30
3) 0.40 x 350 = 140
4) 0.08 x 75 = 6
5) 0.125 x 240 = 30
6) 0.025 x 1,000 = 25
7) 1/3 x 126 = 42
8) 1.75 x 60 = 105
9) 0.005 x 8,000 = 40
10) 2/3 x 54 = 36
1) 18 out of 60
2) 35 out of 140
3) 7 out of 20
4) 48 out of 80
5) 3 out of 8
6) 150 out of 200
7) 9 out of 40
8) 250 out of 400
1) 18/60 x 100 = 30%
2) 35/140 x 100 = 25%
3) 7/20 x 100 = 35%
4) 48/80 x 100 = 60%
5) 3/8 x 100 = 37.5%
6) 150/200 x 100 = 75%
7) 9/40 x 100 = 22.5%
8) 250/400 x 100 = 62.5%
1) $60 increased by 20%
2) $250 decreased by 15%
3) 80 kg increased by 5%
4) 1,200 decreased by 35%
5) $45 increased by 100%
6) A town of 8,000 people grows by 12%. What is the new population?
7) A $320 phone is discounted by 25%, then the sale price is taxed at 10%. What do you pay?
8) A stock goes from $40 to $52. What is the percentage increase?
9) A car depreciates from $25,000 to $18,000. What is the percentage decrease?
10) A salary was $55,000 and is now $60,500. What was the percentage raise?
1) $60 x 1.20 = $72
2) $250 x 0.85 = $212.50
3) 80 x 1.05 = 84 kg
4) 1,200 x 0.65 = 780
5) $45 x 2.00 = $90
6) 8,000 x 1.12 = 8,960 people
7) After discount: $320 x 0.75 = $240. After tax: $240 x 1.10 = $264
8) (52 - 40) / 40 x 100 = 12/40 x 100 = 30%
9) (25,000 - 18,000) / 25,000 x 100 = 7,000/25,000 x 100 = 28%
10) (60,500 - 55,000) / 55,000 x 100 = 5,500/55,000 x 100 = 10%
1) $100 increases by 10%, then increases by 10% again. What is the final value?
2) A population of 5,000 increases by 20% one year, then decreases by 20% the next. What is the final population?
3) A house worth $200,000 increases by 8% per year for 3 years. What is it worth?
4) A car worth $30,000 depreciates by 15% per year. What is it worth after 2 years?
5) A shirt is marked up 40% from cost, then discounted 25% during a sale. If the cost was $20, what is the sale price? Is the shop making a profit?
6) An investment of $5,000 earns 6% compound interest per year. What is it worth after 5 years?
1) $100 x 1.10 x 1.10 = $100 x 1.21 = $121 (not $120!)
2) 5,000 x 1.20 x 0.80 = 5,000 x 0.96 = 4,800 (not back to 5,000!)
3) $200,000 x (1.08)^3 = $200,000 x 1.259712 = $251,942.40
4) $30,000 x (0.85)^2 = $30,000 x 0.7225 = $21,675
5) Marked up: $20 x 1.40 = $28. Sale price: $28 x 0.75 = $21. Yes, the shop makes $1 profit (5% margin on cost).
6) $5,000 x (1.06)^5 = $5,000 x 1.338226 = $6,691.13
1) After a 20% increase, the price is $96. What was the original price?
2) After a 25% discount, a jacket costs $60. What was the original price?
3) Including 8% tax, a meal costs $54. What was the pre-tax price?
4) After a 30% pay cut, a worker earns $35,000. What was the original salary?
5) A TV costs $540 after a 10% discount plus 8% tax on the discounted price. What was the original price?
6) After two years of 5% annual growth, a savings account has $11,025. What was the original deposit?
1) $96 / 1.20 = $80
2) $60 / 0.75 = $80
3) $54 / 1.08 = $50
4) $35,000 / 0.70 = $50,000
5) $540 = Original x 0.90 x 1.08 = Original x 0.972. Original = $540 / 0.972 = $555.56 (approximately)
6) $11,025 / (1.05)^2 = $11,025 / 1.1025 = $10,000
1) Estimated: 50, Actual: 45
2) Estimated: 120, Actual: 150
3) Estimated: 3.5 metres, Actual: 3.2 metres
4) A student guessed there were 200 sweets in a jar. The actual count was 185. What was the percentage error?
5) A weather app predicted 12mm of rain. Only 8mm fell. What is the percentage error?
1) |50 - 45| / 45 x 100 = 5/45 x 100 = 11.11%
2) |120 - 150| / 150 x 100 = 30/150 x 100 = 20%
3) |3.5 - 3.2| / 3.2 x 100 = 0.3/3.2 x 100 = 9.375%
4) |200 - 185| / 185 x 100 = 15/185 x 100 = 8.11%
5) |12 - 8| / 8 x 100 = 4/8 x 100 = 50%
1) $2,000 at 4% simple interest for 5 years. What is the total interest? What is the total amount?
2) $3,000 at 5% compound interest (yearly) for 3 years. What is the final amount?
3) $10,000 at 3% compound interest for 4 years. How much interest is earned in total?
4) Using the Rule of 72: how long to double your money at 9%?
5) Using the Rule of 72: how long to double your money at 4%?
6) You borrow $8,000 at 6% simple interest for 3 years. How much do you repay in total?
7) Which is better: $1,000 at 10% simple interest for 10 years, or $1,000 at 8% compound interest for 10 years?
8) $500 at 12% compound interest, compounded monthly, for 1 year. What is the final amount? (Monthly rate = 12%/12 = 1%)
1) Interest = $2,000 x 0.04 x 5 = $400. Total = $2,000 + $400 = $2,400
2) $3,000 x (1.05)^3 = $3,000 x 1.157625 = $3,472.88
3) $10,000 x (1.03)^4 = $10,000 x 1.12551 = $11,255.09. Interest = $11,255.09 - $10,000 = $1,255.09
4) 72 / 9 = 8 years
5) 72 / 4 = 18 years
6) Interest = $8,000 x 0.06 x 3 = $1,440. Total = $8,000 + $1,440 = $9,440
7) Simple: $1,000 + ($1,000 x 0.10 x 10) = $1,000 + $1,000 = $2,000. Compound: $1,000 x (1.08)^10 = $1,000 x 2.15892 = $2,158.92. Compound wins by $158.92, despite the lower rate!
8) $500 x (1.01)^12 = $500 x 1.12683 = $563.41
1) A shop sells a TV for $600 (which includes a 20% profit margin on cost). What did the shop pay for the TV?
2) In a survey of 800 people, 35% prefer tea, 45% prefer coffee, and the rest prefer water. How many prefer water?
3) A student scored 72%, 85%, 68%, and 91% on four tests. What is their average percentage?
4) A factory produces 1,500 items per day. 4% are defective. How many non-defective items are produced?
5) You earn $3,200 per month. You spend 30% on rent, 15% on food, 10% on transport, and save the rest. How much do you save?
6) A country's GDP grows from $500 billion to $620 billion over 4 years. What is the total percentage growth? What is the average annual growth rate (simple)?
7) A shop buys 200 items at $5 each, sells 150 at $9 each, and has to discount the remaining 50 to $3 each. What is the overall profit or loss percentage?
8) A phone battery loses 2% of its maximum capacity per month. After 12 months, what percentage of its original capacity remains?
9) Two candidates in an election: A gets 55% of the vote, B gets the rest. If A wins by 4,000 votes, how many total votes were cast?
10) A train ticket costs $40. Senior citizens get a 30% discount, and students get a 20% discount. A senior student asks for both discounts. The ticket office applies the senior discount first, then the student discount on the reduced price. What does the senior student pay? Would the order of discounts matter?
1) $600 is 120% of cost. Cost = $600 / 1.20 = $500
2) Water: 100% - 35% - 45% = 20%. People = 0.20 x 800 = 160 people
3) (72 + 85 + 68 + 91) / 4 = 316 / 4 = 79%
4) Non-defective = 96% of 1,500 = 0.96 x 1,500 = 1,440 items
5) Spending: 30% + 15% + 10% = 55%. Saving: 45% of $3,200 = 0.45 x 3,200 = $1,440
6) Total growth: (620 - 500) / 500 x 100 = 120/500 x 100 = 24%. Simple annual average: 24% / 4 = 6% per year
7) Cost: 200 x $5 = $1,000. Revenue: (150 x $9) + (50 x $3) = $1,350 + $150 = $1,500. Profit = $500. Profit % = 500/1,000 x 100 = 50% profit
8) Remaining = (0.98)^12 = 0.7847. So 78.47% of original capacity remains (lost about 21.5%, not 24%)
9) A gets 55%, B gets 45%. Difference = 10% of total = 4,000. Total = 4,000 / 0.10 = 40,000 votes
10) Senior first: $40 x 0.70 = $28. Then student: $28 x 0.80 = $22.40. Order doesn't matter because multiplication is commutative: $40 x 0.70 x 0.80 = $40 x 0.80 x 0.70 = $22.40 either way.
1) A price increases by 20%, then is discounted by x% to return to the original price. What is x?
2) If an investment loses 40% of its value, what percentage gain is needed to break even?
3) Three shops sell the same shirt. Shop A: $50 with 30% off. Shop B: $45 with 20% off. Shop C: $55 with 40% off. Which is cheapest?
4) A bacteria population doubles every 4 hours. Starting with 100 bacteria, what percentage increase occurs in 12 hours?
5) You invest $10,000. Half goes into Account A at 8% compound interest. Half goes into Account B at 6% compound interest. After 5 years, what is the total value? What was the effective overall rate?
6) A car's value drops 20% in year 1, 15% in year 2, and 10% in year 3. If it was originally $40,000, what is the total percentage loss over 3 years?
1) After 20% increase: price is 1.20 of original. To return: 1.20 x (1 - x/100) = 1. So (1 - x/100) = 1/1.20 = 0.8333. x = 100 - 83.33 = 16.67% (NOT 20%!)
2) After 40% loss, you have 60% of original. To get back to 100%: need to go from 60 to 100. Gain needed = 40/60 x 100 = 66.67%
3) A: $50 x 0.70 = $35. B: $45 x 0.80 = $36. C: $55 x 0.60 = $33. Shop C is cheapest at $33
4) In 12 hours, it doubles 3 times (12/4 = 3). 100 x 2^3 = 800. Increase = (800-100)/100 x 100 = 700% increase
5) A: $5,000 x (1.08)^5 = $5,000 x 1.46933 = $7,346.64. B: $5,000 x (1.06)^5 = $5,000 x 1.33823 = $6,691.13. Total = $14,037.77. Gain = $4,037.77 on $10,000 over 5 years. Effective rate: (14,037.77/10,000)^(1/5) - 1 = 1.40378^0.2 - 1 = approximately 7% per year
6) $40,000 x 0.80 x 0.85 x 0.90 = $40,000 x 0.612 = $24,480. Total loss = $15,520. Percentage loss = 15,520/40,000 x 100 = 38.8%
Now go get more reps in. The more problems you solve, the more automatic this becomes:
A ratio compares two (or more) quantities. If a classroom has 12 boys and 8 girls, the ratio of boys to girls is 12 : 8 (read "12 to 8"). Ratios can also be written as fractions: 12/8.
Just like fractions, you simplify ratios by dividing all parts by their GCD.
Simplify 12 : 8
GCD of 12 and 8 is 4.
12 / 4 : 8 / 4 = 3 : 2
Simplify 45 : 30 : 15
GCD of 45, 30, and 15 is 15.
45/15 : 30/15 : 15/15 = 3 : 2 : 1
A proportion states that two ratios are equal. If a/b = c/d, then the two ratios are in proportion.
Cross-multiplication is the key tool for solving proportions. If two fractions are equal, then multiplying diagonally gives equal products.
Solve: 3/4 = x/20
Cross-multiply: 3 x 20 = 4 x x
60 = 4x
x = 60 / 4 = 15
Check: 3/4 = 15/20 = 0.75. Correct!
If 5 apples cost $3, how much do 12 apples cost?
Set up proportion: 5/3 = 12/x
Cross-multiply: 5 x x = 3 x 12
5x = 36
x = 36 / 5 = $7.20
On a map, 2 cm represents 50 km. If two cities are 7 cm apart on the map, how far apart are they in reality?
Proportion: 2/50 = 7/x
Cross-multiply: 2x = 50 x 7 = 350
x = 350 / 2 = 175 km
A recipe for 4 people uses 6 cups of flour. How much flour for 10 people?
Proportion: 4/6 = 10/x
Cross-multiply: 4x = 6 x 10 = 60
x = 60 / 4 = 15 cups
Make sure you set up the proportion with matching units in the same position. If the left side is apples/dollars, the right side must also be apples/dollars -- not dollars/apples. Consistency is key.
A class has 15 boys and 10 girls.
• Part-to-part: Boys to girls = 15:10 = 3:2
• Part-to-whole: Boys to total = 15:25 = 3:5
• Part-to-whole: Girls to total = 10:25 = 2:5
As percentages: Boys = 15/25 = 60%, Girls = 10/25 = 40%
A concrete mix uses cement, sand, and gravel in the ratio 1:2:4. If you need 21 total parts, how much of each?
Total ratio parts = 1 + 2 + 4 = 7
Each part = 21 ÷ 7 = 3 units
Cement = 1 × 3 = 3 units
Sand = 2 × 3 = 6 units
Gravel = 4 × 3 = 12 units
Check: 3 + 6 + 12 = 21 ✓
Some relationships are inversely proportional – as one increases, the other decreases.
Example: It takes 4 workers 6 hours to build a fence. How long for 8 workers?
More workers → Less time, so: Workers × Time = Constant
4 × 6 = 24 worker-hours needed
8 workers need: 24 ÷ 8 = 3 hours
Formula: If w₁t₁ = w₂t₂, then t₂ = (w₁t₁)/w₂
Car A travels 280 miles on 8 gallons. Car B travels 315 miles on 9 gallons. Which is more efficient?
Car A: 280 ÷ 8 = 35 mpg
Car B: 315 ÷ 9 = 35 mpg
They're exactly the same efficiency! Unit rates make comparison easy.
Always ask yourself: "What am I comparing to what?" Write it out in words first, then set up the math. For example: "If 3 apples cost $2, how much do 12 apples cost?" becomes "3 apples is to $2 as 12 apples is to $x" → 3/2 = 12/x.
Ratios are the backbone of many CS concepts:
newHeight = originalHeight * (newWidth / originalWidth)Work through these with pencil and paper. Cross-multiplication is your best friend here.
1) 10 : 15
2) 24 : 36
3) 45 : 60
4) 8 : 12 : 20
5) 100 : 250
6) 14 : 21 : 35
7) 2.5 : 5 (hint: multiply both by 2 first)
8) 0.3 : 0.9
9) 1/2 : 1/3 (hint: find LCD first)
10) 3/4 : 5/8
1) 2 : 3
2) 2 : 3
3) 3 : 4
4) 2 : 3 : 5
5) 2 : 5
6) 2 : 3 : 5
7) 5 : 10 = 1 : 2
8) 3 : 9 = 1 : 3
9) 3/6 : 2/6 = 3 : 2 = 3 : 2
10) 6/8 : 5/8 = 6 : 5 = 6 : 5
1) 3/5 = x/20
2) 7/x = 21/15
3) x/8 = 9/12
4) 4/9 = 16/x
5) 2.5/x = 5/8
6) x/7 = 12/21
7) 15/x = 3/4
8) x/100 = 3/25
9) 8/x = x/18 (hint: cross-multiply to get x^2)
10) 6/10 = 9/x
1) 3 x 20 = 5x → x = 60/5 = 12
2) 7 x 15 = 21x → x = 105/21 = 5
3) 12x = 72 → x = 6
4) 4x = 144 → x = 36
5) 2.5 x 8 = 5x → 20 = 5x → x = 4
6) 21x = 84 → x = 4
7) 3x = 60 → x = 20
8) 25x = 300 → x = 12
9) x^2 = 144 → x = 12
10) 6x = 90 → x = 15
1) A recipe for 6 people needs 4 cups of flour. How much flour for 15 people?
2) On a map, 3 cm represents 75 km. Two cities are 8 cm apart. How far apart are they?
3) A car uses 5 litres of fuel for every 60 km. How much fuel for a 210 km trip?
4) Mix paint in the ratio 3 red : 5 blue. If you use 12 litres of red, how much blue?
5) Share $450 in the ratio 2 : 3 : 4. How much does each person get?
6) 8 workers can build a wall in 6 days. How long for 12 workers? (Inverse proportion)
7) A photo is 4 inches by 6 inches. You want to enlarge it so the longer side is 15 inches. What is the shorter side?
8) A school has a student-to-teacher ratio of 18:1. If there are 540 students, how many teachers?
9) A concrete mix uses cement, sand, and gravel in the ratio 1:3:5. You need 27 tonnes total. How much of each?
10) If 3 machines produce 180 items in 2 hours, how many items do 5 machines produce in 3 hours?
1) 6/4 = 15/x → 6x = 60 → x = 10 cups
2) 3/75 = 8/x → 3x = 600 → x = 200 km
3) 5/60 = x/210 → 60x = 1050 → x = 17.5 litres
4) 3/5 = 12/x → 3x = 60 → x = 20 litres blue
5) Total parts = 9. Each part = $50. Shares: $100, $150, $200
6) Workers x Days = constant. 8 x 6 = 48. 12 x d = 48 → d = 4 days
7) 4/6 = x/15 → 6x = 60 → x = 10 inches
8) 540/x = 18/1 → 18x = 540 → x = 30 teachers
9) Total parts = 9. Each part = 3 tonnes. Cement: 3, Sand: 9, Gravel: 3, 9, 15 tonnes
10) 3 machines make 180 in 2 hours = 90/hour for 3 machines = 30 per machine per hour. 5 machines x 3 hours x 30 = 450 items
An exponent tells you how many times to multiply a number by itself. In x^n, x is the base and n is the exponent (or power).
Think of it as a pattern: 2^3 = 8, 2^2 = 4, 2^1 = 2. Each time the exponent decreases by 1, we divide by 2. So 2^0 = 2/2 = 1. It works for every base.
| Rule | Formula | Example |
|---|---|---|
| Product Rule | x^a * x^b = x^(a+b) | 2^3 * 2^4 = 2^7 = 128 |
| Quotient Rule | x^a / x^b = x^(a-b) | 5^6 / 5^2 = 5^4 = 625 |
| Power of a Power | (x^a)^b = x^(a*b) | (3^2)^3 = 3^6 = 729 |
| Power of a Product | (x * y)^n = x^n * y^n | (2 * 3)^4 = 2^4 * 3^4 = 16 * 81 = 1296 |
| Power of a Quotient | (x / y)^n = x^n / y^n | (4/3)^2 = 16/9 |
Simplify: 3^2 * 3^5
Product rule: same base, add exponents: 3^(2+5) = 3^7 = 2187
Simplify: (4^3)^2
Power of a power: 4^(3*2) = 4^6 = 4096
Simplify: 10^8 / 10^5
Quotient rule: 10^(8-5) = 10^3 = 1000
A negative exponent means "take the reciprocal." It flips the number to the other side of the fraction bar.
A square root asks: "What number multiplied by itself gives this?" The square root of 25 is 5, because 5 x 5 = 25.
These are numbers whose square roots are whole numbers. Memorizing them makes math much faster.
| n | n^2 (Perfect Square) | n | n^2 (Perfect Square) |
|---|---|---|---|
| 1 | 1 | 8 | 64 |
| 2 | 4 | 9 | 81 |
| 3 | 9 | 10 | 100 |
| 4 | 16 | 11 | 121 |
| 5 | 25 | 12 | 144 |
| 6 | 36 | 13 | 169 |
| 7 | 49 | 14 | 196 |
If a number is not a perfect square, estimate by finding which two perfect squares it falls between. For example, sqrt(50): since 7^2 = 49 and 8^2 = 64, sqrt(50) is between 7 and 8 -- closer to 7 (it is approximately 7.07).
A surd is a root that cannot be simplified to a whole number. sqrt(4) = 2 is not a surd because it simplifies cleanly. But sqrt(2) = 1.41421356... goes on forever with no repeating pattern -- it can never be written as a neat fraction. That's a surd.
The word "surd" comes from the Latin "surdus" meaning "deaf" or "mute" -- because these numbers can't "speak" as clean fractions. They are irrational numbers.
You might ask: "Why write sqrt(2) instead of 1.414?" Because the decimal is an approximation, but sqrt(2) is exact. In math, keeping the surd form preserves perfect precision. If you need the decimal later (for code or measurement), you convert at the end.
What is the diagonal of a unit square (side = 1)?
By Pythagoras: diagonal = sqrt(1² + 1²) = sqrt(2)
If you write 1.414, that's approximately right. But sqrt(2) is exactly right.
This matters when you chain calculations -- rounding errors accumulate.
The key rule: sqrt(a × b) = sqrt(a) × sqrt(b). Use this to pull out perfect square factors.
Step 1: What perfect square divides 50? 25 does (25 × 2 = 50)
Step 2: sqrt(50) = sqrt(25 × 2) = sqrt(25) × sqrt(2)
Step 3: sqrt(25) = 5, so the answer is 5 sqrt(2)
Step 1: What perfect square divides 72? 36 does (36 × 2 = 72)
Step 2: sqrt(72) = sqrt(36 × 2) = sqrt(36) × sqrt(2)
Step 3: 6 sqrt(2)
Step 1: 48 = 16 × 3 (16 is the largest perfect square factor)
Step 2: sqrt(48) = sqrt(16 × 3) = sqrt(16) × sqrt(3)
Step 3: 4 sqrt(3)
Always use the largest perfect square factor. If you simplify sqrt(48) using 4 × 12 instead of 16 × 3, you get 2 sqrt(12) -- which is correct but not fully simplified (sqrt(12) still has a perfect square factor of 4). You'd need another step: 2 × 2 sqrt(3) = 4 sqrt(3). Using the largest factor saves time.
You can only add or subtract surds that have the same number under the root (same "type" of surd). Think of it like variables: you can add 3x + 2x = 5x, but you can't add 3x + 2y.
3 sqrt(2) + 5 sqrt(2) = 8 sqrt(2) ✓ (same root, add coefficients)
7 sqrt(3) - 2 sqrt(3) = 5 sqrt(3) ✓
3 sqrt(2) + 4 sqrt(5) = 3 sqrt(2) + 4 sqrt(5) (cannot combine -- different roots)
Tricky one: sqrt(50) + sqrt(18)
These look different, but simplify first:
sqrt(50) = 5 sqrt(2) and sqrt(18) = 3 sqrt(2)
Now they're the same type! 5 sqrt(2) + 3 sqrt(2) = 8 sqrt(2)
Multiplication is straightforward: sqrt(a) × sqrt(b) = sqrt(a × b). Multiply the numbers under the roots.
sqrt(3) × sqrt(3) = sqrt(9) = 3 (a surd times itself = the number inside!)
sqrt(2) × sqrt(8) = sqrt(16) = 4
2 sqrt(3) × 5 sqrt(7) = (2 × 5) × sqrt(3 × 7) = 10 sqrt(21)
3 sqrt(5) × 4 sqrt(5) = 12 × sqrt(25) = 12 × 5 = 60
Division works the same way: sqrt(a) / sqrt(b) = sqrt(a / b).
In math, it's considered bad form to leave a surd in the denominator of a fraction. Rationalising means getting rid of the surd on the bottom. Multiply top and bottom by the surd:
Multiply top and bottom by sqrt(3):
1 / sqrt(3) × sqrt(3) / sqrt(3) = sqrt(3) / 3
Answer: sqrt(3) / 3
Why does this work? Because sqrt(3) × sqrt(3) = 3, which eliminates the surd from the bottom.
Multiply top and bottom by sqrt(2):
5 / sqrt(2) × sqrt(2) / sqrt(2) = 5 sqrt(2) / 2
Answer: 5 sqrt(2) / 2
When the denominator has a surd added to something, multiply by the conjugate (flip the sign on the surd part):
Conjugate of (3 + sqrt(2)) is (3 - sqrt(2))
6 / (3 + sqrt(2)) × (3 - sqrt(2)) / (3 - sqrt(2))
Bottom: (3 + sqrt(2))(3 - sqrt(2)) = 9 - 2 = 7 (difference of squares!)
Top: 6(3 - sqrt(2)) = 18 - 6 sqrt(2)
Answer: (18 - 6 sqrt(2)) / 7
The conjugate trick uses the difference of squares identity: (a + b)(a - b) = a² - b². When b is a surd, b² eliminates the root: (sqrt(2))² = 2. This always clears the surd from the denominator.
| Surd | Approximate Value | Where You'll See It |
|---|---|---|
| sqrt(2) ≈ 1.414 | 1.41421356... | Diagonal of a unit square, 45° triangle |
| sqrt(3) ≈ 1.732 | 1.73205080... | Equilateral triangle height, 30-60-90 triangle |
| sqrt(5) ≈ 2.236 | 2.23606797... | The Golden Ratio = (1 + sqrt(5)) / 2 |
| sqrt(10) ≈ 3.162 | 3.16227766... | Decibel calculations |
In programming, you rarely write "sqrt(2)" symbolically -- you just compute math.sqrt(2) and get 1.4142135... as a float. But understanding surds helps you in several ways:
Exponents are the single most important pre-algebra concept for CS. Here's why:
When someone says "that algorithm is exponential," they mean it's unusably slow for large inputs. Understanding exponents lets you instantly judge whether an approach will work.
Work through each problem by hand. For exponents, write out the multiplication. For square roots, think about which perfect squares are nearby.
1) 2^5
2) 3^4
3) 5^3
4) 10^6
5) 7^0
6) 1^100
7) 4^3
8) 2^10
9) 6^2
10) 9^3
1) 32
2) 81
3) 125
4) 1,000,000
5) 1 (anything to the power 0 is 1)
6) 1
7) 64
8) 1,024
9) 36
10) 729
1) 2^3 x 2^4
2) 5^7 / 5^3
3) (3^2)^3
4) 4^5 x 4^(-2)
5) 10^8 / 10^8
6) (2 x 5)^3
7) 6^4 / 6^6
8) (7^3)^2 / 7^4
9) 3^2 x 3^3 x 3^(-1)
10) (2^3 x 2^2)^2
1) 2^(3+4) = 2^7 = 128
2) 5^(7-3) = 5^4 = 625
3) 3^(2x3) = 3^6 = 729
4) 4^(5-2) = 4^3 = 64
5) 10^(8-8) = 10^0 = 1
6) 2^3 x 5^3 = 8 x 125 = 1,000 (or 10^3)
7) 6^(4-6) = 6^(-2) = 1/36
8) 7^6 / 7^4 = 7^2 = 49
9) 3^(2+3-1) = 3^4 = 81
10) (2^5)^2 = 2^10 = 1,024
1) 2^(-4)
2) 5^(-2)
3) 10^(-3)
4) 3^(-3)
5) (1/2)^(-3)
6) 4^(-1)
7) (2/3)^(-2)
8) 10^(-1) + 10^(-2)
1) 1/16 = 0.0625
2) 1/25 = 0.04
3) 1/1000 = 0.001
4) 1/27
5) 2^3 = 8 (flip the fraction, positive exponent)
6) 1/4 = 0.25
7) (3/2)^2 = 9/4 = 2.25
8) 0.1 + 0.01 = 0.11
1) sqrt(49)
2) sqrt(144)
3) sqrt(225)
4) cbrt(64)
5) Simplify: sqrt(18)
6) Simplify: sqrt(75)
7) Simplify: sqrt(200)
8) Simplify: sqrt(98)
9) Estimate sqrt(40) to 1 decimal place (between which two perfect squares?)
10) Simplify: 3 x sqrt(12)
11) Simplify: sqrt(8) x sqrt(2)
12) Simplify: sqrt(45) + sqrt(20)
1) 7
2) 12
3) 15
4) 4
5) sqrt(9 x 2) = 3 sqrt(2)
6) sqrt(25 x 3) = 5 sqrt(3)
7) sqrt(100 x 2) = 10 sqrt(2)
8) sqrt(49 x 2) = 7 sqrt(2)
9) 6^2 = 36, 7^2 = 49. sqrt(40) is between 6 and 7, closer to 6. Approx 6.3
10) 3 x sqrt(4 x 3) = 3 x 2 sqrt(3) = 6 sqrt(3)
11) sqrt(8 x 2) = sqrt(16) = 4
12) 3 sqrt(5) + 2 sqrt(5) = 5 sqrt(5)
Negative numbers are numbers less than zero. They show up everywhere in real life: debt (you owe $50 = -$50), temperature below freezing (-15 degrees), floors below ground level (basement = -1), or losing points in a game. On the number line, they live to the left of zero.
<--- negative --- 0 --- positive --->
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
The further left you go, the smaller the number. -10 is less than -3, even though 10 "looks" bigger than 3. Think of it like temperature: -10 degrees is way colder (smaller) than -3 degrees.
Here is the key insight: the sign tells you direction, and the number tells you distance. +5 means "5 steps to the right of zero." -5 means "5 steps to the left of zero." They are the same distance from zero, just in opposite directions.
Before memorizing any rules, let's build the intuition. Think of positive numbers as money you have and negative numbers as money you owe. Addition means combining them together.
This is what you already know. You have $3 and you get $5 more. You now have $8. Nothing new here.
You owe $3 and then you owe $5 more. You now owe $8 total. When you combine two debts, the debt gets bigger. So you add the numbers and keep the negative sign.
On the number line: start at -3 (already left of zero). Adding -5 means move 5 more steps to the left. You land on -8. Two negatives added together always make a bigger negative.
This is where it gets interesting. You have $7 but you owe $3. What's your actual situation? You subtract the smaller from the bigger: 7 - 3 = 4. Since you had more than you owed, the answer is positive: +4.
The rule: when the signs are different, subtract the smaller number from the bigger one, then take the sign of whichever number was bigger (ignoring the sign, just looking at the size).
Here is the single most useful trick in all of basic math: subtraction is just adding the opposite. Every subtraction problem can be turned into an addition problem. Once you see this, subtraction with negatives becomes easy.
a - b = a + (-b)
To subtract any number, just flip its sign and add instead. That is it. Every subtraction problem in existence follows this rule.
This is normal subtraction you already know. 10 - 4 = 6. But let's see it through the lens of our rule: 10 - 4 becomes 10 + (-4) = 6. Same answer.
What does 5 - (-3) mean? Using our rule: flip the sign of -3 (it becomes +3) and add. So 5 - (-3) = 5 + 3 = 8.
Imagine you owe someone $3 (that's -3 in your life). Now someone says "I'm removing that debt." Removing a debt is a good thing -- it's like gaining money. So subtracting a negative (removing something bad) is the same as adding a positive (gaining something good). Two negatives cancel out.
Every addition/subtraction problem with signs boils down to two questions:
Same signs? Add the numbers, keep that sign. (-3) + (-5) = -8
Different signs? Subtract the smaller from bigger, take the sign of the bigger. (-9) + 4 = -5
And for subtraction: just flip the second sign and turn it into addition. Then use the rules above.
Multiplication and division follow a completely different (and simpler) pattern than addition and subtraction. There is one rule that handles everything:
That is the entire rule. Let's make sure you understand why it works.
3 x 4 = 12. Obvious. You have 3 groups of 4. Nothing surprising.
3 x (-4) = -12. Think of it as: you have 3 groups of "losing 4 dollars." If you lose $4 three times, you have lost $12 total. That is -12.
(-3) x 4 = -12. Multiplication can be done in any order (3 x 4 = 4 x 3), so this is the same situation as above, just flipped. Still -12.
(-3) x (-4) = 12. This is the one that confuses people. Here is the best way to think about it:
Imagine you have a debt of $4 per month (-4). Now imagine we remove 3 months of that debt (-3 months of -$4). Removing debt is a good thing -- you have effectively gained $12. So (-3) x (-4) = +12.
Another way: look at the pattern.
(-3) x 3 = -9
(-3) x 2 = -6
(-3) x 1 = -3
(-3) x 0 = 0
(-3) x (-1) = ?
Each time we decrease the second number by 1, the answer goes up by 3. So the next answer must be +3. The pattern forces negative x negative to be positive.
| First Number | Second Number | Result | Why |
|---|---|---|---|
| + (positive) | + (positive) | + (positive) | Same signs |
| - (negative) | - (negative) | + (positive) | Same signs |
| + (positive) | - (negative) | - (negative) | Different signs |
| - (negative) | + (positive) | - (negative) | Different signs |
Think of it like friends and enemies: a friend of a friend is a friend (+)(+)=(+). An enemy of an enemy is a friend (-)(-)=(+). A friend of an enemy is an enemy (+)(-)=(-). An enemy of a friend is an enemy (-)(+)=(-).
Division follows the exact same sign rules as multiplication. No new rules to learn.
When you multiply several negative numbers together, there is a simple counting trick:
Addition & Subtraction: Convert everything to addition (flip sign if subtracting). Then: same signs = add and keep sign. Different signs = subtract and keep sign of the bigger.
Multiplication & Division: Same signs = positive. Different signs = negative. Count negatives if chaining: even = positive, odd = negative.
That is genuinely all you need. Every problem with signs uses one of these rules.
Negative numbers aren't just math theory -- they're a daily tool in programming:
arr[-1] gives you the last element, arr[-2] the second-to-last. This uses negative number arithmetic under the hood: -1 + len(arr).signed int ranges from -128 to 127. Understanding sign rules helps you understand why.Negative numbers trip people up because the rules feel backwards at first. The only way to make them automatic is practice. Use a number line if it helps.
1) -3 + 7
2) -5 + (-8)
3) 4 - 9
4) -6 - 3
5) -12 + 12
6) -7 - (-4)
7) 15 + (-20)
8) -8 - (-8)
9) -3 + 5 - 7 + 2
10) -15 + 8 - (-3) + (-6)
11) -100 + 45 - 30
12) -2.5 + 4.8
1) 4
2) -13
3) -5
4) -9
5) 0
6) -7 + 4 = -3
7) -5
8) -8 + 8 = 0
9) (-3 + 5) + (-7 + 2) = 2 + (-5) = -3
10) -15 + 8 + 3 - 6 = -10
11) -85
12) 2.3
1) -3 x 5
2) -4 x (-6)
3) 7 x (-8)
4) -9 x (-9)
5) -2 x 3 x (-4)
6) (-1)^5
7) -36 / 6
8) -48 / (-8)
9) 56 / (-7)
10) -100 / (-25)
11) -2 x (-3) x (-4)
12) (-5)^2 vs -(5^2)
1) -15
2) 24
3) -56
4) 81
5) (-2 x 3) x (-4) = -6 x -4 = 24
6) -1 (odd number of negatives = negative)
7) -6
8) 6
9) -8
10) 4
11) 6 x (-4) = -24 (odd number of negatives = negative)
12) (-5)^2 = 25 but -(5^2) = -25. The brackets make all the difference!
1) -3 + 4 x (-2)
2) (-5)^2 - 3 x 6
3) -8 / 2 + 3 x (-4)
4) |(-7) + 3| (absolute value)
5) |-5| x |-3|
6) -2 x (5 - 8)
7) (-3)^3 + 10
8) (4 - 7) x (2 - 5)
9) -1 x (-1) x (-1) x (-1) x (-1)
10) 20 / (-4) - (-3)^2
1) -3 + (-8) = -11
2) 25 - 18 = 7
3) -4 + (-12) = -16
4) |-4| = 4
5) 5 x 3 = 15
6) -2 x (-3) = 6
7) -27 + 10 = -17
8) (-3) x (-3) = 9
9) -1 (5 negatives = negative)
10) -5 - 9 = -14
1) The temperature is -8°C at midnight. By noon it rises 15°C. What is the temperature at noon?
2) A submarine is at -120 metres. It rises 45 metres, then dives 30 metres. What is its final depth?
3) Your bank balance is $250. You make purchases of $80, $45, and $190. What is your balance now?
4) A lift (elevator) starts at floor 3, goes down 7 floors, then up 2 floors. What floor is it on?
5) The difference between two temperatures is 35°C. If one temperature is -12°C, what could the other temperature be? (Two answers)
6) A stock opens at $45, drops $8, rises $3, drops $12, rises $5. What is the closing price? What was the net change?
1) -8 + 15 = 7°C
2) -120 + 45 - 30 = -105 metres
3) 250 - 80 - 45 - 190 = -$65 (overdrawn!)
4) 3 - 7 + 2 = -2 (2 floors below ground/basement level 2)
5) -12 + 35 = 23°C or -12 - 35 = -47°C
6) 45 - 8 + 3 - 12 + 5 = $33. Net change = 33 - 45 = -$12
Modular arithmetic answers one question: "What is the remainder when I divide?" You already know this intuitively. If you have 17 cookies and split them among 5 people, each person gets 3, and you have 2 left over. That remainder -- 2 -- is the result of 17 mod 5 (or 17 % 5 in code).
The easiest way to understand mod is a clock. A clock cycles from 1 to 12, then wraps back around. If it's 10 o'clock and you add 5 hours, you don't get 15 o'clock -- you get 3 o'clock. That's because 15 mod 12 = 3. The number "wraps around" when it reaches the limit.
This "wrapping" behaviour is exactly what makes mod so powerful in programming.
The single most common use of mod in all of programming:
n % 2 == 0 → n is even
n % 2 == 1 → n is odd
Why? Even numbers divide by 2 with no remainder. Odd numbers always have remainder 1.
12 % 2 = 0 (even) 13 % 2 = 1 (odd) 0 % 2 = 0 (even)
You have an array of 5 elements (indices 0-4). You want to cycle through them forever:
This pattern is used in circular buffers, round-robin scheduling, rotating through players in a game, and carousel UIs.
Want the last digit of 1234? Use mod 10:
1234 % 10 = 4 (last digit)
Want the last two digits? Use mod 100:
1234 % 100 = 34
This is how you reverse numbers, check palindromes, and extract parts of numbers in coding problems.
Convert 200 minutes to hours and minutes:
Hours: 200 / 60 = 3 (integer division -- see next section)
Minutes: 200 % 60 = 20
Answer: 3 hours 20 minutes
This is how every clock app works: totalSeconds % 60 gives seconds, (totalSeconds / 60) % 60 gives minutes, totalSeconds / 3600 gives hours.
Here's a gotcha: -7 % 5 behaves differently depending on the language.
If you're using C++ or JavaScript and need a positive remainder from a negative number, use: ((a % n) + n) % n. This is a common interview trick and a real-world bug source.
index = hash(key) % table_size -- this is literally how every hash map works. The mod ensures the hash fits within the array bounds.next = (current + 1) % size wraps around without if-statements.if (n % 3 == 0) print("Fizz").index / 10, position on page = index % 10.hue = (hue + 1) % 360 cycles through colours forever.If you learn one math operation deeply, make it mod. You will use it more than any other arithmetic in code.
The % operator will become one of your most-used tools in programming. Master it here.
1) 17 % 5
2) 23 % 7
3) 100 % 3
4) 45 % 9
5) 31 % 6
6) 256 % 10
7) 7 % 7
8) 3 % 8
9) 1000 % 7
10) 99 % 100
11) 144 % 12
12) 50 % 8
1) 17 = 3x5 + 2 → 2
2) 23 = 3x7 + 2 → 2
3) 100 = 33x3 + 1 → 1
4) 45 = 5x9 + 0 → 0 (divides evenly)
5) 31 = 5x6 + 1 → 1
6) 6 (last digit!)
7) 0
8) 3 (when number < mod, the result is the number itself)
9) 1000 = 142x7 + 6 → 6
10) 99
11) 0
12) 50 = 6x8 + 2 → 2
1) Is 247 even or odd? (Use mod 2)
2) Is 3,456 divisible by 3? (Use mod 3)
3) What day of the week is it 100 days from Monday? (Mon=0, Tue=1, ... Sun=6)
4) A clock shows 10:00. What time does it show 27 hours later? (mod 12)
5) You have 50 items and display 8 per page. How many pages? How many items on the last page?
6) FizzBuzz: For numbers 1-20, which ones are divisible by both 3 and 5?
7) An array has 7 elements (indices 0-6). If you keep incrementing an index with (i+1) % 7, what sequence of indices do you get starting from 5?
8) A hash table has 10 buckets. Where does a key with hash value 437 go?
9) You want to split 23 tasks evenly among 4 workers. How many tasks does each worker get? How many workers get an extra task?
10) What is the last digit of 7^4? (Hint: only need 7^4 % 10)
1) 247 % 2 = 1, so odd
2) 3+4+5+6 = 18, 18 % 3 = 0, so yes, divisible by 3
3) 100 % 7 = 2. Monday + 2 = Wednesday
4) (10 + 27) % 12 = 37 % 12 = 1:00
5) Pages = ceil(50/8) = 7 pages. Last page: 50 % 8 = 2 items
6) Divisible by 15: 15 (only one in range 1-20)
7) 5, 6, 0, 1, 2, 3, 4, 5, ... it wraps around in a circle
8) 437 % 10 = bucket 7
9) 23 / 4 = 5 remainder 3. Each worker gets 5 tasks, and 3 workers get an extra task.
10) 7^4 = 2401, last digit = 1
When you divide 7 by 2, the answer is 3.5. But what if you need a whole number? You have two choices: round down (floor) or round up (ceiling). These aren't just rounding -- they have precise mathematical definitions and they show up in programming constantly.
The floor of a number is the largest integer that is less than or equal to it. Written as ⌊x⌋. Think of it as "chopping off the decimal" -- but be careful with negatives.
⌊-2.3⌋ = -3, not -2. Floor always goes toward negative infinity. This catches people off guard. -3 is less than -2.3, so the floor is -3.
The ceiling of a number is the smallest integer that is greater than or equal to it. Written as ⌈x⌉. Think of it as "always round up unless already whole."
In most programming languages, dividing two integers gives you integer division -- the decimal part is thrown away. In C++, Java, and JavaScript (using Math.trunc), this truncates toward zero, which is different from floor for negative numbers.
-7 / 2 in C++ gives -3 (truncation). -7 // 2 in Python gives -4 (floor). This difference has caused countless bugs when porting code between languages. Always test with negative numbers.
You have 47 items and show 10 per page. How many pages do you need?
Wrong answer: 47 / 10 = 4 (but that only covers 40 items!)
Right answer: ⌈47 / 10⌉ = ⌈4.7⌉ = 5 pages
In code (without a ceiling function): (47 + 10 - 1) / 10 = 56 / 10 = 5
The trick (a + b - 1) / b computes ceiling using only integer division. Memorize this -- it comes up in interviews.
Binary search finds the middle index: mid = (low + high) / 2
If low = 3 and high = 8: mid = 11 / 2 = 5 (integer division, floors automatically)
If low = 3 and high = 7: mid = 10 / 2 = 5 (exact)
Integer division naturally gives you the floor, which is exactly what binary search needs.
Convert 3725 seconds:
Hours: 3725 / 3600 = 1 (integer division)
Remaining: 3725 % 3600 = 125
Minutes: 125 / 60 = 2
Seconds: 125 % 60 = 5
Result: 1:02:05
Notice how integer division and mod work together perfectly -- division gives the "big unit," mod gives the leftover.
mid = (low + high) / 2 uses integer division (floor) to find the middle element.totalPages = ceil(totalItems / itemsPerPage) -- every web app does this.aligned = ceil(size / 8) * 8.itemsPerThread = ceil(totalItems / numThreads) ensures no items are skipped.numRows = ceil(items / columns) tells you how many rows a grid needs.Floor rounds down, ceiling rounds up, and integer division truncates toward zero. These show up in programming constantly.
1) x = 3.7
2) x = -2.3
3) x = 5.0
4) x = -0.1
5) x = 7.999
6) x = -4.8
7) x = 0.001
8) x = -1.0
9) x = 99.5
10) x = -0.999
1) floor = 3, ceil = 4
2) floor = -3, ceil = -2
3) floor = 5, ceil = 5 (already a whole number)
4) floor = -1, ceil = 0
5) floor = 7, ceil = 8
6) floor = -5, ceil = -4
7) floor = 0, ceil = 1
8) floor = -1, ceil = -1 (already a whole number)
9) floor = 99, ceil = 100
10) floor = -1, ceil = 0
1) 17 // 5
2) 23 // 4
3) 100 // 7
4) 7 // 10
5) 50 // 6
6) 255 // 8
7) 999 // 100
8) 1 // 3
9) 63 // 9
10) 1000 // 3
1) 3 (17 / 5 = 3.4, truncate = 3)
2) 5 (23 / 4 = 5.75)
3) 14 (100 / 7 = 14.28...)
4) 0 (7 / 10 = 0.7)
5) 8 (50 / 6 = 8.33...)
6) 31 (255 / 8 = 31.875)
7) 9
8) 0
9) 7
10) 333
1) You have 47 students and each bus holds 12. How many buses do you need? (Use ceil)
2) You have 100 items to display, 15 per page. How many pages? How many on the last page?
3) A binary search on an array of 100 elements: what is the midpoint index? (Use floor of (0 + 99) / 2)
4) You need to split 1,000 tasks across 7 threads. How many tasks per thread? How many threads get an extra task?
5) Memory alignment: you need 37 bytes but memory must be aligned to 8-byte boundaries. How many bytes do you actually allocate? (Use ceil(37/8) x 8)
6) A video is 185 seconds long. Express this in minutes and seconds using integer division and mod.
7) You have $47 and items cost $6 each. How many can you buy? How much money is left?
8) A grid has 4 columns and 23 items. How many rows are needed?
1) ceil(47/12) = ceil(3.917) = 4 buses
2) Pages = ceil(100/15) = 7 pages. Last page: 100 % 15 = 10 items
3) floor(99/2) = floor(49.5) = index 49
4) 1000 // 7 = 142 tasks each. Extra: 1000 % 7 = 6 threads get an extra task.
5) ceil(37/8) x 8 = 5 x 8 = 40 bytes
6) Minutes: 185 // 60 = 3 minutes. Seconds: 185 % 60 = 5 seconds. So 3:05.
7) Items: 47 // 6 = 7 items. Left: 47 % 6 = $5
8) ceil(23/4) = ceil(5.75) = 6 rows
Test your understanding with these 5 questions. Click an answer to check it -- you will get immediate feedback and an explanation.