# AP Computer Science 3.5 Review of the Basics

###### Recommendation

### Want a study guide too?

Using the modulo in arithmetic.

AP | AP Computer Science |

AP Computer Science | Review of the Basics |

Computer Science | AP Computer Science |

Language | English Language |

Standard Operations and Algorithms | Operations on data structures |

Test Prep | AP Computer Science |

### Transcript

science and math are joined at the hip and it

sounds like this is at its core a simple math

question The module o operator often represented by a percent

sign and shortened to mod will return the remainder of

those two values after division takes place So for example

the result of five mod too would be one since

that's the remainder you'd get from dividing two into five

in another case twelve mod for would return zero because

there'd be no remainder after dividing twelve by four just

be three and nothing left over So this question is

asking us to give mod precedence over multiplication This brings

us all the way back to the order of operations

Or pam does he remember pim das Rights are buddy

We're going to be using that here with ma djalo

ahead of multiplication in line So let's show that preference

by putting ma djalo operations in parentheses Well we'll start

with four mod five before divided by five zero with

a remainder of four so we'll get a four There

are ten mod seven would be three because ten divided

by seven is one with remainder of three Then we

have four month three which will be one of three

dozen foreign there's One left over and now we're left

with two times four divided by three times one Well

two times four eight of course and three times one

is three So now we're down A divided by three

eight five two three is too pulling six six six

six six forever like devil But all the possible answers

here our imagers So we'll convert this rather than rounding

up converting the repeating two point six six six two

an imager is this name is mouring The number that

will get two instead of three on Our answer is

c it's all well and good That module exists But

when would a person actually use it Well one real

world application of modular is to check if the number

is odd or even if ex mod to return zero

That means there was no remainder X is divisible by

two And therefore even if you were to expand that

idea outward and write a method to check any given

number to see if it's divisible by anything but one

and itself well you have built your first automated prime

number validator conquering mathematics and ushering in the reign of 00:02:35.275 --> [endTime] universal king module it's One a Divisive Later indeed