Question

In: Computer Science

Find the largest number of divisions made by Euclid’s algorithm for computing gcd(m, n) for 1≤...

Find the largest number of divisions made by Euclid’s algorithm for computing gcd(m, n) for 1≤ n ≤ m ≤ 100.

Solutions

Expert Solution

Answer: 

#Largest number of divisions was: 11 for m:55 and n:89

Using the below program we find that for numbers 55 and 89 the largest number of division was maximum and it is 11

======================================================================

count = 0
def gcd(a, b):
    global count
    count += 1
    if (b == 0):
        return a
    else:
        return gcd(b, a % b)


def main():
    global count
    largest_divisions = count
    num_m = num_n = 0
    for m in range(1, 101):
        for n in range(1, 101):
            gcd(m, n)
            if largest_divisions < count:
                largest_divisions = count
                num_m = m
                num_n = n
            count = 0
    print('Largest number of divisions was: {} for m:{} and n:{}'.format(largest_divisions,num_m,num_n))

main()


Related Solutions

11. Use Euclid’s extended algorithm to find x and y for Gcd(241, 191) = 241 x...
11. Use Euclid’s extended algorithm to find x and y for Gcd(241, 191) = 241 x + 191 y Show all work.
Find the GCD (5796852, 4585268) using the Euclidian Algorithm..
Find the GCD (5796852, 4585268) using the Euclidian Algorithm..
Find the GCD (5796852, 4585268) using the Euclidian Algorithm..
Find the GCD (5796852, 4585268) using the Euclidian Algorithm..
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).
use euclidean algorithm to find integers m,n such that 1693m+2019n=1
use euclidean algorithm to find integers m,n such that 1693m+2019n=1
1. Must be nicely written up AS A PROOF. a. Show that gcd(m + n, m)...
1. Must be nicely written up AS A PROOF. a. Show that gcd(m + n, m) = gcd(m, n). b. If n | k(n + 1), show that n | k. c. Show that any two consecutive odd integers are relatively prime.
Use Euclid’s algorithm to find integers x, y and d for which 3936x + 1293y =...
Use Euclid’s algorithm to find integers x, y and d for which 3936x + 1293y = d is the smallest possible positive integer. Using your answers to this as your starting point, do the following tasks. (a)Find an integer s that has the property that s ≡ d mod 3936 and s ≡ 0 mod 1293. (b) Find an integer S that has the property that S ≡ 573 mod 3936 and S ≡ 0 mod 1293. (c) Find an...
Use the Euclidean algorithm to find the GCD of 3 + 9i and 7-i
Use the Euclidean algorithm to find the GCD of 3 + 9i and 7-i
Use Euclid’s algorithm to find integers x, y and d for which 3936 x + 1293...
Use Euclid’s algorithm to find integers x, y and d for which 3936 x + 1293 y = d is the smallest possible positive integer. Using your answers to this as your starting point, do the following tasks. (a) Find a solution of 3936 x ≡ d mod 1293. (b) Find an integer r that has the property that r ≡ d mod 1293 and r ≡ 0 mod 3936. (c) Find an integer R that has the property that...
NUMBER THEORY 1.Use the Euclidian algorithm to calculate the GCD of 1160718174 and 316258250. 2.Use Fermat’s...
NUMBER THEORY 1.Use the Euclidian algorithm to calculate the GCD of 1160718174 and 316258250. 2.Use Fermat’s Little Theorem to solve for x^86 ≡ 6 (mod 29).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT