Question

In: Computer Science

Find the greatest common divisor d = gcd(527, 341). Show all calculation steps. We assume that...

Find the greatest common divisor d = gcd(527, 341). Show all calculation steps.

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

Solutions

Expert Solution

We can use the Euclidean Algorithm here to find GCD of two numbers.

  • If X = 0 then GCD(X,Y)=Y, since the GCD(0,Y)=Y, stop.
  • If B = 0 then GCD(X,Y)=X, since the GCD(X,0)=X, stop.
    • Write X in quotient remainder form (X= Y⋅P + D) where P is quotient and D is remainder
  • Find GCD(Y,R) using the Euclidean Algorithm since GCD(X,Y) = GCD(Y,R)

GCD(527,341) =
X = 527, Y = 341
X ≠ 0 , Y ≠ 0
527 = 341 * 1 + 186
GCD(527,341) = GCD(341,186)

Again,
GCD(341,186)
X = 341, Y = 186
X ≠ 0 , Y ≠ 0
341 = 186 * 1 + 155
GCD(341,186) = GCD(186,155)

GCD(186, 155)
X = 186, Y = 155
X ≠ 0 , Y ≠ 0
186 = 151 * 1 + 31
GCD(186,155) = GCD(155,31)

GCD(155,31)
X = 155, Y = 31
X ≠ 0 , Y ≠ 0
155 = 31 * 5 + 0
GCD(155,31) = GCD(31,0)

And by Euclidean algorithm GCD(31, 0 ) = 31

Hence GCD(527, 341 ) = 31.

The modulus of the follwing:

X mod Y : X = Y*A + R (where A is quotient and R is remainder) R is the answer
But if Y is negative then X mod Y = M , X mod -Y = -(Y-M)
a) 7 mod 4 -> 7 = 4 * 1 + 3 = 3
b) 7 mod -4 -> 7 mod 4 = 3 , Using above -(4-3) = -1
c) -7 mod 4 -> -7 = 4*-2 + 1 = 1
d) -7 mod -4 -> -7 = -4 *1 +(-3) = -3


Related Solutions

3. In mathematics, the greatest common divisor (gcd), sometimes known as the greatest common factor (gcf)...
3. In mathematics, the greatest common divisor (gcd), sometimes known as the greatest common factor (gcf) or highest common factor (hcf), of two non-zero integers, is the largest positive integer that divides both numbers. The greatest common divisor of a and b is written as gcd (a, b), or sometimes simply as (a, b). For example, gcd (12, 18) = 6, gcd (−4, 14) = 2 and gcd (5, 0) = 5. Two numbers are called co-prime or relatively prime...
Write a C function gcd that returns the greatest common divisor of two integers. The greatest...
Write a C function gcd that returns the greatest common divisor of two integers. The greatest common divisor (GCD) of two integers is the largest integer that evenly divides each of the two numbers.
In C++ The greatest common divisor (GCD) of two integers in the largest integer that evenly...
In C++ The greatest common divisor (GCD) of two integers in the largest integer that evenly divides each of the numbers. Write a function called GCD that has a void return type, and accepts 3 parameters (first two by value, third by reference). The function should find the greatest common divisor of the first two numbers, and have the result as its OUTGOING value. Write a main function that asks the users for two integers, and uses your function to...
Let m, n be natural numbers such that their greatest common divisor gcd(m, n) = 1....
Let m, n be natural numbers such that their greatest common divisor gcd(m, n) = 1. Prove that there is a natural number k such that n divides ((m^k) − 1).
A. 271 and 516 1.  Find the greatest common divisor, d, of the two numbers from part...
A. 271 and 516 1.  Find the greatest common divisor, d, of the two numbers from part A using the Euclidean algorithm. Show and explain all work. 2.  Find all solutions for the congruence ax ? d (mod b) where a and b are the integers from part A and d is the greatest common divisor from part A1. Show and explain all work.
Using python pls!!!!! Write a recursive function gcd(m,n) that returns the greatest common divisor of a...
Using python pls!!!!! Write a recursive function gcd(m,n) that returns the greatest common divisor of a pair of numbers. The gcd of m and n is the largest number that divides both m and n. If one of the numbers is 0, then the gcd is the other number. If m is greater than or equal to n, then the gcd of m and n is the same as the gcd of n and m-n. If n is greater than...
Let a and b be positive integers, and let d be their greatest common divisor. Prove...
Let a and b be positive integers, and let d be their greatest common divisor. Prove that there are infinitely many integers x and y such that ax+by = d. Next, given one particular solution x0 and y0 of this equation, show how to find all the solutions.
4. (a) Use the Euclidean algorithm to find the greatest common divisor of 21 and 13,...
4. (a) Use the Euclidean algorithm to find the greatest common divisor of 21 and 13, and the greatest common divisor of 34 and 21. (b) It turns out that 21 and 13 is the smallest pair of numbers for which the Euclidean algorithm requires 6 steps (for every other pair a and b requiring 6 or more steps a > 21 and b > 13). Given this, what can you say about 34 and 21? (c) Can you guess...
All necessary steps much show for these problems, please. Use the Euclidean algorithm to find gcd(12345,...
All necessary steps much show for these problems, please. Use the Euclidean algorithm to find gcd(12345, 54321). Write gcd(2420, 70) as a linear combination of 2420 and 70. The work to obtain the gcd is provided. 2420 = 34(70) + 40 70 = 1(40) + 30 40 = 1(30) + 10 30 = 3(10) + 0 Determine if 1177 is prime or not. If it is not, then write 1177 as a product of primes Find gcd(8370, 465) by unique...
Please show all the steps of calculation. The following are the financial statements for Patriots and...
Please show all the steps of calculation. The following are the financial statements for Patriots and Jets Companies for 2018: Statements of Financial Position Patriots Jets Cash $  25,000 $  45,000 Accounts receivable (net) 55,000 5,000 Inventory 110,000 25,000 Property, plant, and equipment (net) 550,000 160,000 Other long-term assets 140,000 57,000 Total assets $880,000 $292,000 Accounts payable $110,000 $  10,000 Salaries payable 10,000 5,000 Current liabilities $120,000 $  15,000 Long-term liabilities 190,000 55,000 Total liabilities $310,000 $  70,000 Common shares 530,000 214,000 Retained earnings 40,000...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT