# Group Work - Remainder Operator (%)

Each coding exercise has its own folder. Open its `.java` file and press **Run** to try it.

It is best to use a POGIL approach with the following. In POGIL students work in groups on activities and each member has an assigned role. For more information see [https://cspogil.org/Home](https://cspogil.org/Home). This page is based on a POGIL activity from Helen Hu at that site.

Look at the expressions in the code above and the output. Then answer the following questions.

## Exercise 1

Run the code to see what it prints.

> Open the `01-mod-model-1` folder and run `ModModl1.java`. It is an example, so it has no tests.

> Check your understanding: Review the code in `01-mod-model-1`. What is the first number (n) such that `n % 4` returns zero? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-which-returns-zero

> Check your understanding: Review the code in `01-mod-model-1`. What is the next number (n) (greater than 16) such that `n % 4` returns zero? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-next-returns-zero

## Going Beyond Remainder 4

> Check your understanding: What is the first number from 1 to 10 that is evenly divisible by five (`n % 5` returns 0)? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-return-zero-mod-five

> Check your understanding: What is the last number from 1 to 10 that is evenly divisible by five (`n % 5` returns 0)? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-return-zero-mod-five-last

## Look Deeper

Look at the code above for the numbers such that `n % 4` returns 1. How do these numbers differ from the ones that return zero?

> Discuss this with your class, or answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-returns-one-sa

## More Practice

> Check your understanding: What is the number returned from `18 % 4`? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-18-mod-4

> Check your understanding: What is the number returned from `19 % 4`? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-19-mod-4

> Check your understanding: What is the number returned from `19 % 5`? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-19-mod-5

> Check your understanding: What is the number returned from `19 % 6`? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-19-mod-6

## Long Division with a Remainder

Consider how you did long division in elementary school where you determined what number goes evenly into another number and the remainder.

![Mod ex](images/mod-ex.png)

> Check your understanding: What number is the remainder when you divide 79 by 5? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-79-mod-5

## Dividing Evenly

Imagine if you were given candies to evenly divide amoung members of a group of four people. Follow kindergarten rules where every group member gets the same number of candies and the extras go back to the teacher.

> Check your understanding: How many candies go back to the teacher when you are given 11 candies? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-11-mod-4

> Check your understanding: How many candies go back to the teacher when you are given 2 candies? — answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-2-mod-4

## Describe the Remainder (%) Operator

Describe what % does in your own words. Use complete sentences.

> Discuss this with your class, or answer it on CS Awesome: https://runestone.academy/ns/books/published/csawesome2/group-mod-practice.html#mod-describe-mod-sa
