---
title: "Remainder Operator (%) — AP CSA Definition & Examples"
description: "The remainder operator (%) returns what's left over after integer division in Java. Learn how AP CSA tests it alongside / in expressions like 15 % 4."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/remainder-operator"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 1"
---

# Remainder Operator (%) — AP CSA Definition & Examples

## Definition

In AP Computer Science A, the remainder operator (%) is the arithmetic operator that evaluates to the remainder after dividing one number by another, so 15 % 4 evaluates to 3. It is one of Java's five arithmetic operators (+, -, *, /, %) covered in Topic 1.3.

## What It Is

The remainder operator (%) is one of Java's five arithmetic [operators](/ap-comp-sci-a/unit-1/expressions-and-assignment-statements/study-guide/01dr6uUPDAn3SjtK2Psr "fv-autolink"), alongside addition, subtraction, multiplication, and division (EK 1.3.C.2). It answers a simple question. After you divide one number by another using [integer division](/ap-comp-sci-a/key-terms/integer-division "fv-autolink"), what's left over? So `15 % 4` is `3`, because 4 goes into 15 three times (that's 12) with 3 remaining. Think of it as the partner to `/`. Integer division gives you the quotient, and `%` gives you everything `/` threw away.

Like the other arithmetic operators, `%` follows Java's type rules. If both operands are `int`, the result is an `int`. If at least one operand is a `double`, the result is a `double`. The classic uses you'll see all over AP code are checking if a number is even (`n % 2 == 0`), grabbing the last digit of a number (`n % 10`), and wrapping a value back to zero when it hits a limit. One Java quirk worth memorizing is that with negative numbers, the result takes the sign of the left operand, so `-7 % 3` is `-1`, not `2`.

## Why It Matters

The remainder operator lives in Topic 1.3 (Expressions and Assignment Statements) in [Unit 1](/ap-comp-sci-a/unit-1 "fv-autolink"), supporting learning objective 1.3.C, which asks you to develop code for [arithmetic expressions](/ap-comp-sci-a/key-terms/arithmetic-expression "fv-autolink") and determine what they evaluate to. That phrase "determine the result" is the whole game. The AP exam loves handing you a code segment with `/` and `%` mixed together and asking exactly what prints, because it tests whether you actually understand integer arithmetic or just skimmed it. Beyond Unit 1, `%` keeps showing up for the rest of the course. Even/odd checks in loop conditions, digit-by-digit number processing, and cycling through positions in a list all run on the remainder operator, so a shaky grasp of it in Unit 1 costs you points in every later unit.

## Connections

### [Integer Division (Unit 1)](/ap-comp-sci-a/key-terms/integer-division)

Division and remainder are two halves of the same operation. `15 / 4` gives you 3 (the integer quotient) and `15 % 4` gives you 3 (the leftover). The exam pairs them constantly, because if you understand one, you can sanity-check the other. Quotient times divisor plus remainder gets you back to the original number.

### [Operator Precedence (Unit 1)](/ap-comp-sci-a/key-terms/operator-precedence)

In Java, `%` has the same precedence as `*` and `/`, and operators at the same level evaluate left to right. That's why `25 % 7 % 3` means `(25 % 7) % 3`, which is `4 % 3`, which is 1. [Tracing](/ap-comp-sci-a/key-terms/tracing "fv-autolink") chained operators is a favorite MCQ move.

### [Modular Arithmetic (Unit 1)](/ap-comp-sci-a/key-terms/modular-arithmetic)

The remainder operator is how Java does [modular arithmetic](/ap-comp-sci-a/key-terms/modular-arithmetic "fv-autolink"), the math of clocks and cycles. When you write `hour % 12` or `index % array.length`, you're wrapping a value around so it never exceeds a limit. This idea powers circular traversal patterns you'll write in later units.

### [Arithmetic Expression (Unit 1)](/ap-comp-sci-a/key-terms/arithmetic-expression)

Per EK 1.3.C.1, `%` is one of the building blocks of arithmetic expressions, combining with values and variables to produce `int` or `double` results. The int-vs-double evaluation rule applies to `%` exactly like it applies to every other arithmetic operator.

## On the AP Exam

Remainder shows up in "what is printed?" multiple-choice questions, usually right next to integer division. A typical stem gives you something like `int x = 15; int y = 4;` and asks what `x / y` and `x % y` print (here, `3 3`). Harder versions chain operators, like `25 % 7 % 3`, where you have to apply left-to-right evaluation step by step. On FRQs, `%` rarely gets named in the prompt, but you'll reach for it yourself when a problem says "every other element," "the last digit," "divisible by," or "wraps around." Writing `n % 2 == 0` for evenness or `n % d == 0` for divisibility is one of the most reusable moves in the whole course. The skill the CED demands (LO 1.3.C) is twofold. You have to trace expressions that use `%` and produce the exact output, and you have to write expressions using `%` when a problem secretly calls for it.

## remainder operator vs integer division (/)

With two int operands, `/` keeps the whole-number quotient and throws away the remainder, while `%` keeps the remainder and throws away the quotient. For `15 / 4` you get 3 because 4 fits into 15 three times. For `15 % 4` you also get 3, but for a different reason. That's the leftover after taking out three 4s. They happen to match here, which is exactly why this example shows up on tests. Quick check: `(x / y) * y + (x % y)` always equals `x`.

## Key Takeaways

- The remainder operator (%) evaluates to what's left over after integer division, so 15 % 4 is 3 and 20 % 5 is 0.
- An expression like n % d equals 0 exactly when n is divisible by d, which makes n % 2 == 0 the standard even-number check.
- The % operator has the same precedence as * and /, and same-level operators evaluate left to right, so 25 % 7 % 3 means (25 % 7) % 3, which is 1.
- If both operands are int the result is an int, and if at least one operand is a double the result is a double, just like every other arithmetic operator (EK 1.3.C.2).
- With negative operands, the result takes the sign of the left operand, so -7 % 3 evaluates to -1 in Java.
- The result of x % y is always smaller in magnitude than y, which is why % is the go-to tool for wrapping values around a limit.

## FAQs

### What is the remainder operator in Java?

It's the % symbol, one of Java's five arithmetic operators (EK 1.3.C.2). It evaluates to the remainder after dividing the left operand by the right one, so 15 % 4 is 3 and 12 % 4 is 0.

### Does % calculate a percentage in Java?

No. Despite the symbol, % has nothing to do with percentages in Java. It computes the remainder of a division, so 50 % 100 is 50, not half. Reading % as "percent" is one of the fastest ways to miss an Unit 1 MCQ.

### What's the difference between / and % in Java?

With two ints, / gives the whole-number quotient and % gives the leftover. For 25 and 7, 25 / 7 is 3 and 25 % 7 is 4. Together they recover the original number, since 3 * 7 + 4 = 25.

### What does a negative number mod give you in Java, like -7 % 3?

In Java, -7 % 3 evaluates to -1, not 2. The result of % takes the sign of the left operand. This trips up students coming from [math class](/ap-comp-sci-a/unit-1/using-the-math-class/study-guide/6e652tzJOa5eE5mjPATE "fv-autolink"), where mod is usually defined to be non-negative.

### How do you check if a number is even using the remainder operator?

Use n % 2 == 0. If the remainder when dividing by 2 is zero, the number is even. The same [pattern](/ap-comp-sci-a/unit-1/why-programming-why-java/study-guide/lVK6rmrBuug17i1Hna9z "fv-autolink") generalizes, since n % d == 0 is true exactly when n is divisible by d, a check you'll write constantly on FRQs.

## Related Study Guides

- [1.3 Expressions and Assignment Statements](/ap-comp-sci-a/unit-1/expressions-and-assignment-statements/study-guide/01dr6uUPDAn3SjtK2Psr)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/remainder-operator#resource","name":"Remainder Operator (%) — AP CSA Definition & Examples","url":"https://fiveable.me/ap-comp-sci-a/key-terms/remainder-operator","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/remainder-operator#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T05:27:19.101Z","isPartOf":{"@type":"Collection","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/remainder-operator#term","name":"remainder operator","description":"In AP Computer Science A, the remainder operator (%) is the arithmetic operator that evaluates to the remainder after dividing one number by another, so 15 % 4 evaluates to 3. It is one of Java's five arithmetic operators (+, -, *, /, %) covered in Topic 1.3.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/remainder-operator","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the remainder operator in Java?","acceptedAnswer":{"@type":"Answer","text":"It's the % symbol, one of Java's five arithmetic operators (EK 1.3.C.2). It evaluates to the remainder after dividing the left operand by the right one, so 15 % 4 is 3 and 12 % 4 is 0."}},{"@type":"Question","name":"Does % calculate a percentage in Java?","acceptedAnswer":{"@type":"Answer","text":"No. Despite the symbol, % has nothing to do with percentages in Java. It computes the remainder of a division, so 50 % 100 is 50, not half. Reading % as \"percent\" is one of the fastest ways to miss an Unit 1 MCQ."}},{"@type":"Question","name":"What's the difference between / and % in Java?","acceptedAnswer":{"@type":"Answer","text":"With two ints, / gives the whole-number quotient and % gives the leftover. For 25 and 7, 25 / 7 is 3 and 25 % 7 is 4. Together they recover the original number, since 3 * 7 + 4 = 25."}},{"@type":"Question","name":"What does a negative number mod give you in Java, like -7 % 3?","acceptedAnswer":{"@type":"Answer","text":"In Java, -7 % 3 evaluates to -1, not 2. The result of % takes the sign of the left operand. This trips up students coming from [math class](/ap-comp-sci-a/unit-1/using-the-math-class/study-guide/6e652tzJOa5eE5mjPATE \"fv-autolink\"), where mod is usually defined to be non-negative."}},{"@type":"Question","name":"How do you check if a number is even using the remainder operator?","acceptedAnswer":{"@type":"Answer","text":"Use n % 2 == 0. If the remainder when dividing by 2 is zero, the number is even. The same [pattern](/ap-comp-sci-a/unit-1/why-programming-why-java/study-guide/lVK6rmrBuug17i1Hna9z \"fv-autolink\") generalizes, since n % d == 0 is true exactly when n is divisible by d, a check you'll write constantly on FRQs."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science A","item":"https://fiveable.me/ap-comp-sci-a"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-a/key-terms"},{"@type":"ListItem","position":3,"name":"Unit 1","item":"https://fiveable.me/ap-comp-sci-a/unit-1"},{"@type":"ListItem","position":4,"name":"remainder operator"}]}]}
```
