SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
William Stallings
Chapter:
Introduction To Number Theory
Exercise:
Problems
Question:4 | ISBN:9781292158587 | Edition: 7

Question

In this text, we assume that the modulus is a positive integer. But the definition of the expression a mod n also makes perfect sense if n is negative. Determine the following:
a. 7 mod 4
b. 7 mod -4
c. -7 mod 4
d. -7 mod -4

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

You are correct that the modulus operation can be defined for negative values of "n". In such cases, we consider the remainder to be negative or zero to maintain consistency with the definition of modulo for positive values of "n". Let's determine the results for the given expressions:

a)

Given data:7 mod 4:

When performing the modulus operation with a positive modulus, we look for the remainder when 7 is divided by 4.

7 mod 4 = 3

 

b)

Given data: 7 mod -4:

When performing the modulus operation with a negative modulus, we look for the remainder when 7 is divided by -4. To determine this, we consider the negative remainder values.

7 mod -4 = -1

c)

Given data:-7 mod 4:

Here, we consider the remainder when -7 is divided by 4, taking into account the negative remainder values.

-7 mod 4 = -3

d)

Given data: -7 mod -4:

Finally, let's determine the remainder when -7 is divided by -4. We consider the negative remainder values.

-7 mod -4 = -3

To summarize:

a. 7 mod 4 = 3

b. 7 mod -4 = -1

c. -7 mod 4 = -3

d. -7 mod -4 = -3

0 0

Discussions

Post the discussion to improve the above solution.