---
title: "AP CSP 3.3: Mathematical Expressions and MOD"
description: "Review AP Computer Science Principles Topic 3.3, including mathematical expressions, MOD, modulus, arithmetic operators, order of operations, sequencing, algorithms, pseudocode, and evaluating code segments."
canonical: "https://fiveable.me/ap-comp-sci-p/unit-3/mathematical-expressions/study-guide/00lGBdF7QyY5hmd1rubD"
type: "study-guide"
subject: "AP Computer Science Principles"
unit: "Unit 3 – Algorithms & Programming Fundamentals"
lastUpdated: "2026-06-08"
---

# AP CSP 3.3: Mathematical Expressions and MOD

## Summary

Review AP Computer Science Principles Topic 3.3, including mathematical expressions, MOD, modulus, arithmetic operators, order of operations, sequencing, algorithms, pseudocode, and evaluating code segments.

## Guide

## TLDR
Mathematical expressions in [AP Computer Science Principles](/ap-comp-sci-p "fv-autolink") are about evaluating arithmetic to a single value and putting steps in the right order. You need to know the five [arithmetic operators](/ap-comp-sci-p/key-terms/arithmetic-operators "fv-autolink") (`+`, `-`, `*`, `/`, `MOD`), how `MOD` finds a remainder, and how order of operations decides what gets evaluated first. Sequencing means statements run top to bottom in the order they appear.

## Why This Matters for the AP Computer Science Principles Exam

This topic builds the foundation for almost every [code segment](/ap-comp-sci-p/key-terms/code-segment "fv-autolink") you will read on the exam. Multiple-choice questions often ask you to determine the result of a code segment, and that usually starts with evaluating an [expression](/ap-comp-sci-p/key-terms/expression "fv-autolink") correctly. The exam uses its own pseudocode on a reference sheet, so being comfortable with operators like `MOD` and the `/` symbol is a regular requirement.

Beyond multiple-choice, expressing an [algorithm](/ap-comp-sci-p/key-terms/algorithm "fv-autolink") using sequencing without a programming language shows up when you describe steps in natural language, a diagram, or pseudocode. When you build your program for the [Create performance task](/ap-comp-sci-p/key-terms/create-performance-task "fv-autolink"), sequencing and arithmetic are the basic moves you combine into larger logic.

## Key Takeaways

- An algorithm is a finite set of instructions that accomplishes a specific task, and it can be written as natural language, a diagram, or pseudocode, not only in a programming language.
- Every algorithm can be built from combinations of sequencing, [selection](/ap-comp-sci-p/key-terms/selection "fv-autolink"), and [iteration](/ap-comp-sci-p/unit-3/iteration/study-guide/7megnIMaNHzDdrVKT9mR "fv-autolink").
- Sequencing means each statement runs in the order it appears, one after another.
- An expression can be a value, a [variable](/ap-comp-sci-p/key-terms/variable "fv-autolink"), an [operator](/ap-comp-sci-p/key-terms/operator "fv-autolink"), or a procedure call that returns a value, and it always evaluates to a single value.
- The arithmetic operators are `+`, `-`, `*`, `/`, and `MOD`; `a MOD b` gives the remainder when `a` is divided by `b`.
- Order of operations decides what evaluates first, and on the exam reference sheet `MOD` has the same precedence as `*` and `/`.

## Algorithms and Sequencing

An algorithm is a finite set of instructions that accomplishes a specific task. That definition sounds a lot like a program, and the two are closely related, but they are not the same thing. An algorithm is the problem-solving logic, while a program is how you carry it out. Programs execute algorithms.

Think of baking a cake. The algorithm is the set of steps you follow to make the cake. The program is the written recipe that the baker, or the computer, actually runs.

Algorithms can be expressed in many ways. You can write one in a programming language like Java or a block-based language like Scratch for a computer to run. You can also write it in pseudocode, describe it in a natural language like English, or draw it as a diagram. A computer does exactly what you tell it, so be clear and detailed when you turn an algorithm in your head into a program.

### Sequencing, Selection, and Iteration

Every algorithm can be constructed from three building blocks: sequencing, selection, and iteration. These are carried out through code statements, which are parts of program code that express an action to be carried out.

Sequencing is the application of each step in the order the code statements are given. Once one statement runs, the program moves on to the next one.

```
first_number = 7
second_number = 5
sum_value = first_number + second_number
print (sum_value)
```

The computer reads and processes these one after another, top to bottom. Selection and iteration come later in this unit and let you make decisions and repeat steps.

## Expressions

An expression can consist of a value, a variable, an operator, or a procedure call that returns a value. The important part is that an expression always evaluates to a single value.

So `7`, `first_number`, `first_number + second_number`, and a procedure call that hands back a [number](/ap-comp-sci-p/unit-3/variables-assignments/study-guide/vtJhAf5XFOkm1uHNDMvh "fv-autolink") are all expressions. Each one resolves to one value when the program runs.

## Arithmetic Operators

Programs use arithmetic operators for addition, subtraction, multiplication, division, and modulus. On the AP exam reference sheet, the operators are written like this:

- `a + b` adds `a` and `b`
- `a - b` subtracts `b` from `a`
- `a * b` multiplies `a` and `b`
- `a / b` divides `a` by `b`, so `17 / 5` evaluates to `3.4`
- `a MOD b` gives the remainder when `a` is divided by `b`, so `17 MOD 5` evaluates to `2`

Notice that `/` can produce a [decimal](/ap-comp-sci-p/key-terms/decimal "fv-autolink") result on the reference sheet, which is why `17 / 5` is `3.4` and not `3`.

### The MOD Operator

`MOD` is short for modulus, and `a MOD b` gives the remainder of `a` divided by `b`. For example, `13 MOD 3` evaluates to `1`, because 13 divided by 3 is 4 with a remainder of 1. On the reference sheet, `a` is assumed to be an integer greater than or equal to 0, and `b` is an integer greater than 0.

`MOD` shows up constantly in exam questions. It is the standard tool for checking even or odd numbers (`n MOD 2` is `0` for even numbers) and for finding remainders in counting or grouping problems.

🔗 [Code.org](http://code.org) made a visual called the [Modulo Clock](https://studio.code.org/s/allthethings/stage/31/puzzle/1) that shows how MOD wraps around as numbers increase.

## Order of Operations

Expressions are evaluated using an order of operations defined by the programming language, and it generally follows the same PEMDAS rules you use in math. Parentheses first, then multiplication and division, then addition and subtraction, working left to right when operators have equal precedence.

The one detail to memorize is that on the exam reference sheet, `MOD` has the same precedence as `*` and `/`. That means in an expression with multiplication, division, and `MOD` mixed together, you evaluate them left to right in the order they appear.

When in doubt, use parentheses. They override the default precedence and make your intended order clear, which also makes your code easier to read.

## How to Use This on the AP Computer Science Principles Exam

### Code Tracing

When a multiple-choice question asks you to determine the result of a code segment, slow down and evaluate one expression at a time. Substitute the current value of each variable, apply order of operations, and reduce the expression to a single value before moving to the next statement.

### Common Trap

Watch the `MOD` and `/` results carefully. Mixing up a remainder (`MOD`) with a quotient (`/`) is one of the easiest mistakes to make under time pressure. Write out the division as quotient plus remainder if you need to.

### Representing Algorithms Without Code

Some questions or the Create performance task ask you to express steps as an algorithm. You can use natural language, a diagram, or pseudocode. Keep the steps in clear sequential order so the logic is easy to follow.

## Common Misconceptions

- An algorithm and a program are not identical. The algorithm is the logic, and the program is the specific implementation that carries it out.
- `MOD` does not give you the result of the division. It gives the remainder only. `17 / 5` is `3.4`, but `17 MOD 5` is `2`.
- Division on the reference sheet can return a decimal. Do not assume `17 / 5` truncates to `3`.
- `MOD` does not come after multiplication and division in precedence. It shares the same precedence level as `*` and `/`, so you work left to right among them.
- Algorithms are not limited to code. They can be written in natural language, drawn as diagrams, or written in pseudocode.
- Sequencing is not just a minor detail. Changing the order of statements can change the result, since each statement runs in the order it appears.

## Related AP Computer Science Principles Guides

- [3.1 Variables and Assignments](/ap-comp-sci-p/unit-3/variables-assignments/study-guide/vtJhAf5XFOkm1uHNDMvh)
- [Big Idea 3: Algorithms and Programming](/ap-comp-sci-p/unit-3/review/study-guide/eOWMqAJUdtnmttaCSlis)
- [3.12 Calling Procedures](/ap-comp-sci-p/unit-3/calling-procedures/study-guide/lwdr3yhVOtUJZhAmJ5cu)
- [3.18 Undecidable Problems](/ap-comp-sci-p/unit-3/undecidable-problems/study-guide/q0SSR2ddayx397Hy6ztA)
- [3.17 Algorithmic Efficiency](/ap-comp-sci-p/unit-3/algorithmic-efficiency/study-guide/jGSWIqW49BtrQ8dqCWFd)
- [3.2 Data Abstraction](/ap-comp-sci-p/unit-3/data-abstraction/study-guide/kMMTClSiHohfiaHMGFFE)

## Vocabulary

- **addition**: An arithmetic operation represented by the + symbol that combines two numbers to produce their sum.
- **algorithm**: Step-by-step procedures or sets of rules designed to solve a problem or accomplish a task.
- **arithmetic operators**: Symbols used in programming to perform mathematical operations, including addition, subtraction, multiplication, division, and modulus.
- **code statement**: A part of program code that expresses an action to be carried out.
- **division**: An arithmetic operation represented by the / symbol that splits one number by another to produce a quotient.
- **expression**: A combination of a value, variable, operator, or procedure call that can be evaluated to produce a single value.
- **iteration**: A repeating portion of an algorithm that executes a specified number of times or until a given condition is met.
- **modulus operator**: An arithmetic operator represented as MOD that evaluates to the remainder when one integer is divided by another.
- **multiplication**: An arithmetic operation represented by the * symbol that combines two numbers to produce their product.
- **operator**: A symbol or keyword that performs an operation on one or more values or variables.
- **order of operations**: The set of rules that specifies which calculations to perform first in a mathematical expression, with MOD having the same precedence as multiplication and division.
- **procedure call**: A statement that executes a named procedure, interrupting sequential execution and transferring control to the procedure.
- **pseudocode**: A method of expressing an algorithm using a combination of natural language and programming-like syntax, independent of any specific programming language.
- **selection**: A control structure that determines which parts of an algorithm are executed based on whether a condition is true or false.
- **sequencing**: The application of each step of an algorithm in the order in which the code statements are given.
- **sequential code statements**: Lines of code that are executed in the order they appear, one after another.
- **subtraction**: An arithmetic operation represented by the - symbol that finds the difference between two numbers.
- **variable**: A named container in a program that stores a value which can be changed through assignment.

## FAQs

### What are mathematical expressions in AP CSP?

Mathematical expressions are values, variables, operators, or procedure calls that evaluate to one value when a program runs.

### What does MOD mean in AP CSP?

MOD gives the remainder after division. For example, 17 MOD 5 evaluates to 2 because 17 divided by 5 has remainder 2.

### What arithmetic operators are on the AP CSP reference sheet?

The AP CSP reference sheet includes +, -, *, /, and MOD for arithmetic expressions.

### What is the order of operations for MOD?

MOD has the same precedence as multiplication and division, so expressions using *, /, and MOD are evaluated left to right unless parentheses change the order.

### What is sequencing in AP CSP?

Sequencing means statements execute in the order they appear, one after another. Changing the order can change the result.

### How are mathematical expressions tested on the AP CSP exam?

You may need to trace code, substitute variable values, evaluate arithmetic expressions, apply MOD, and follow sequencing to determine a code segment's result.

## Structured Data

```json
{"@context":"https://schema.org","@type":"FAQPage","inLanguage":"en","mainEntity":[{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-p/unit-3/mathematical-expressions/study-guide/00lGBdF7QyY5hmd1rubD#what-are-mathematical-expressions-in-ap-csp","name":"What are mathematical expressions in AP CSP?","acceptedAnswer":{"@type":"Answer","text":"Mathematical expressions are values, variables, operators, or procedure calls that evaluate to one value when a program runs."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-p/unit-3/mathematical-expressions/study-guide/00lGBdF7QyY5hmd1rubD#what-does-mod-mean-in-ap-csp","name":"What does MOD mean in AP CSP?","acceptedAnswer":{"@type":"Answer","text":"MOD gives the remainder after division. For example, 17 MOD 5 evaluates to 2 because 17 divided by 5 has remainder 2."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-p/unit-3/mathematical-expressions/study-guide/00lGBdF7QyY5hmd1rubD#what-arithmetic-operators-are-on-the-ap-csp-reference-sheet","name":"What arithmetic operators are on the AP CSP reference sheet?","acceptedAnswer":{"@type":"Answer","text":"The AP CSP reference sheet includes +, -, *, /, and MOD for arithmetic expressions."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-p/unit-3/mathematical-expressions/study-guide/00lGBdF7QyY5hmd1rubD#what-is-the-order-of-operations-for-mod","name":"What is the order of operations for MOD?","acceptedAnswer":{"@type":"Answer","text":"MOD has the same precedence as multiplication and division, so expressions using *, /, and MOD are evaluated left to right unless parentheses change the order."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-p/unit-3/mathematical-expressions/study-guide/00lGBdF7QyY5hmd1rubD#what-is-sequencing-in-ap-csp","name":"What is sequencing in AP CSP?","acceptedAnswer":{"@type":"Answer","text":"Sequencing means statements execute in the order they appear, one after another. Changing the order can change the result."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-p/unit-3/mathematical-expressions/study-guide/00lGBdF7QyY5hmd1rubD#how-are-mathematical-expressions-tested-on-the-ap-csp-exam","name":"How are mathematical expressions tested on the AP CSP exam?","acceptedAnswer":{"@type":"Answer","text":"You may need to trace code, substitute variable values, evaluate arithmetic expressions, apply MOD, and follow sequencing to determine a code segment's result."}}]}
```
