Documents about Greatest Common Divisor

 

hw9

Washington University in St. Louis, CS 200
Excerpt: ... CSE 200 Spring 2008, HW 9 due date: April 1, in or before class. (just to remind you the hw submission policy 1) 30% if submitted after the class but on the same due day (on Tuesday) 2) 50% if submitted the next day (on Wednesday) 3) no homework will be accepted after Wednesday Study the lecture notes on recursion (lectures 8 and 9) for this set of problems. Problem 1. (5 points) Given two positive integers m and n such that m<n, the greatest common divisor (GCD) of m and n is the same as the greatest common divisor of m and (n-m), and the GCD of 0 and any nonzero integer n is n. Use this fact to write a recursive function GCD(m, n) to compute the greatest common divisor of m and n. Problem 2. (8 points) Given a contiguous function f(x) and two values a and b, we know f(a) < 0 and f(b) > 0. Design a divide-and-conquer strategy and write a recursive function to find a root of f(x), i.e., to find an x such that f(x) = 0 to certain precision, where the precision can be a parameter to your function. Hint: you ...

exer1

Grand Valley State, REED 03
Excerpt: ... d prints the quotient and remainder: $ java DivisionAlgorithm 10 5 1 1 q = 8 + -2 i, r = 0 + -1 i Optional Exercise 3: Implement the Euclidean Algorithm to nd the greatest common divisor of two Gaussian integers by creating a class method public static GaussianInteger gcd(GaussianInteger a, GaussianInteger b) Here is a helpful fact: given two Gaussian integers a and b, and Gaussian integers q and r such that a = bq + r, the greatest common divisor of a and b is the same as the greatest common divisor of b and r . This fact leads to the Euclidean Algorithm, presented for the integers in Chapter 1 of the notes. Optional Exercise 4: Study the class java.lang.String and write a program that reads a String from the command line and writes it backward. $ java Backward Hello olleH ...

CPSC5115_Ch01

Columbus State University, CPSC 5115
Excerpt: ... be sufficiently basic that it can in principle be carried out by a person using only a pencil and paper. It is not enough that each operation be definite as in (iii), but it must be feasible. [Hor76] The effectiveness criterion might be restated as it being possible to map each step in the algorithm to a simple instruction in the base computer language. This violates the idea that algorithms exist independently of programming languages but corresponds to the basic practice that algorithms are quite often expressed using a programming language. The first algorithm for study is Euclids algorithm for computing the greatest common divisor of two positive integers. This algorithm has a very simple expression apart from any programming language. For integers M and N (assume M N), gcd(M, N) = gcd (N, M mod N) The book computes gcd(60,24) = 12. Lets compute a more interesting example. gcd(225, 63) = gcd(63, 36) = gcd(36, 27) = gcd(27, 9) = gcd(9, 0) =9 as 225 = 63 3 + 36, so 225 mod 63 = 36 as 63 = 36 ...

exer1

Grand Valley State, REED 05
Excerpt: ... Rational r) such that x.isIntegerMultipleOf(r) returns true if x = nr where n is an integer. Construct another program to test your Rational class. Exercise 4: Implement the Euclidean Algorithm to nd the greatest common divisor of two Gaussian integers by creating a class method public static GaussianInteger gcd(GaussianInteger a, GaussianInteger b) Here is a helpful fact: given two Gaussian integers a and b, and Gaussian integers q and r such that a = bq + r, the greatest common divisor of a and b is the same as the greatest common divisor of b and r . This fact leads to the Euclidean Algorithm, presented for the integers in Chapter 1 of the notes. Exercise 5: Study the class java.lang.String and write a program that reads a String from the command line and writes it backward. $ java Backward Hello olleH ...

lecture15

Allan Hancock College, MATH 3962
Excerpt: ... he irreducibles elements are p, p N a prime. For Z the positive irreducible elements, had the property p|ab implies p|a or p|b. This stronger notion is taken as the definition of primes in general. Definition 15.2 An element p of a commutative ring R which is not not 0 or a unit is called a prime if p|ab implies p|a or p|b. Lemma 15.3 Let R be an integral domain and p R a prime. Then p is irreducible. Proof Suppose p = ab. We show one of a, b is a unit and the other an associate of p. Now p = ab implies p|ab. So p|a or p|b. In the case p|a, a = pc for some c R, which gives p1 = p = (pc)b = p(bc) Because R is an integral domain we conclude bc = 1. Hence b and c are units. So a p and b is a unit. In the case p|b we conclude similarly a is a unit and b an associate of p. The converse is not true in general, but it is true for Z or any F [x], F a field, and more generally in any principal ideal domain R, and the proof is modelled on the case R = Z. Definition 15.4 ( Greatest Common Divisor ) Let R be an inte ...

hmwk5

N. Illinois, MATH 523
Excerpt: ... Math 523 Total: 20 points Homework 5 Due 7/28/2008 From Section 4 of the lecture notes: 1. Give a multiplication table for GF (32 ). Find all generators for the cyclic group GF (32 ) , and nd the minimal polynomial of each generator over Z3 . 2. Find all generators for the cyclic group of nonzero elements of GF (24 ), and nd the minimal polynomial of each generator over Z2 . 3. Let m, n be positive integers with gcd(m, n) = d. Show that over any eld the greatest common divisor of xm 1 and xn 1 is xd 1. Hint: Use the Euclidean algorithm. 4. If E and F are subelds of GF (pk ) with pm and pn elements respectively, use the previous exercise to show that E F contain pd elements, where d = gcd(m, n). ...

RA02_0113DM

Simpson, CMSC 250
Excerpt: ... CmSc 250 DM Intro to Algorithms Reading assignment for Week 2 due on 01/13 (Tuesday) by 5 pm Read Sections 2.4.1 , 2.4.2 ,2.4.3, 2.4.4 and the lecture notes for Week 2 The first two paragraphs of Section 2.4.4 would seem very foggy, but do not be discouraged just ignore the confusing moments, sunshine will come later. Read very carefully starting with Binary Search. Study the code in Fig. 2.9 and run the program on paper for a simple array, e.g. 2, 5, 6, 8, 9, 10, searching for 5. You should be able to find the number in three loop runs. Examine Euclid's algorithm for finding the greatest common divisor of two integers. Run the code in Fig.2.10 on paper for the integers 16 and 12 ( greatest common divisor - 4). The last part of Section 2.4.4 - Exponentiation, should be relatively easy. Here is the question for this reading assignment: Show that x30 can be computed with 7 multiplications. The questions below apply to your general understanding of the bigOh notation issues. We will discuss them on Wednesday. So ...

inclass25

Evansville, CS 210
Excerpt: ... CS 210 - Fundamentals of Programming I Spring 2006 - In-class exercise for 4/13/06 10 points Names: This exercise should be completed in pairs. The purpose of this exercise is to gain experience writing recursive functions. Here is a problem statement, analysis, and design for today's exercise. Problem Statement For some applications, we need to find the greatest common divisor of two positive integers, that is, the largest integer that divides both numbers. (One number q divides another number p if there is no remainder from p/q. In C+ code, this would mean that p % q = 0.) The Greek mathematician Euclid devised the following recursive algorithm to compute the greatest common divisor (GCD) of two numbers, m and n. if n <= m and n divides m, then GCD(m, n) is n if n > m, then GCD(m, n) is GCD(n, m) otherwise GCD(m, n) is GCD(n, the remainder of m divided by n) This algorithm states that if n is the smaller number and n divides m, then the GCD is n. If m is the smaller number, then the GCD determinati ...

300F07HW3

IUPUI, MATH 300
Excerpt: ... Math 300 Homework 3 Due October 4 1. Use the Eucilidean Algorithm to nd the greatest common divisor of each of given pairs of integers (Note that the rst two of these are the same as 5(c) and 5(d) on Homework 2): (a) (c) (e) 3003 and 2805 7469 and 2464 2947 and 3997 (b) (d) (f ) 11433 and 23051 2689 and 4001 1109 and 4999 2. For each pair of numbers m and n in Exercise 1, nd integers x and y so that the greatest common divisor d of m and n satises d = mx + ny. 3. Let a, b, and m be non-zero integers and suppose d is the greatest common divisor of a and b. Prove that md is the greatest common divisor of ma and mb. Denition If b and c are integers, not 0, such that b|m and c|m, we say m is a common multiple of b and c. Of course, bc is a common multiple of the integers b and c and, indeed, if n is any integer, nbc is also a common multiple of b and c. Thus, any pair of non-zero integers has innitely many positive common multiples. The least common multiple of b and c is the smallest of th ...

Week9

East Los Angeles College, MAS 2213
Excerpt: ... MAS2213/3213 Week 9 (20/424/4) Computer Based Assessment II. Practice Mode opens Monday 20 April at 8am; Exam Mode opens Monday 27 April at 8am; deadline for hand in: Midnight between Monday 4 May and Tuesday 5 May. We will discuss the CBA II Exercises in the tutorial Friday 24 April, and there is also a drop in session Friday 1 May. Z[ d] = { x + y d | x, y Z }. Let and be elements of Z[ d] which are not both zero. We dened a greatest common divisor of and to be an element such that | and | |. Note that in quadratic number rings, we do not dene the greatest common divisor . However, we showed that if and have a greatest common divisor , then any two greatest common divisor s, say 1 and 2 , are related by 2 = 1 where is an invertible element. It was proved that if Z[ d] has Division with Remainders, then greatest common divisor s exist, and and have a greatest common divisor which can be written in the form + . We saw th ...

hw9Sol

Washington University in St. Louis, CS 200
Excerpt: ... CSE 200 Spring 2008, HW 9 due date: April 1, in or before class. (just to remind you the hw submission policy 1) 30% if submitted after the class but on the same due day (on Tuesday) 2) 50% if submitted the next day (on Wednesday) 3) no homework will be accepted after Wednesday Study the lecture notes on recursion (lectures 8 and 9) for this set of problems. Problem 1. (5 points) Given two positive integers m and n such that m<n, the greatest common divisor (GCD) of m and n is the same as the greatest common divisor of m and (n-m), and the GCD of 0 and any nonzero integer n is n. Use this fact to write a recursive function GCD(m, n) to compute the greatest common divisor of m and n. function GCD=GCDsoln1(a,b) if (b=0) GCD=a else GCDsoln1(b,mod(a,b) %you can also use "rem" end function GCD=GCDsoln2(m,n) if m>n big=m; little=n; else big=n; little=m; end if little=0; GCD=big; else GCD=GCDsoln2(little,big-little); end %Note: Watch out to make sure that your function is ending instead %of calling itself agai ...

cong1

N. Illinois, SEC 420
Excerpt: ... The Euclidean Algorithm Yet Again Youve seen how the Euclidean Algorithm encapulates how to solve ax + by = d, where d is the greatest common divisor of a and b. Rewrite this equation as ax d = by. In other words, b divides ax d. So the Euclidean Algorithm can be used to solve congruences of the type ax d (mod b), where d is the greatest common divisor of a and b. More generally, Theorem 1.1.6 says when one can solve ax + by = c: exactly when the greatest common divisor of a and b divides c. Thus, one can solve the congruence ax c (mod b) if and only if the greatest common divisor of a and b divides c. Moreover, if it can be solved, the Euclidean algorithm can be used to nd a solution. Some simpler, but illuminating examples: 15x 2 (mod 51) 15x 2 (mod 50) 15x 3 (mod 51) 1 Now suppose m and n are relatively prime. Then there are integers h and k with hm + kn = 1. Note how this one equation tells us the following two congruences: hm 1 (mod n) kn 1 (mod m). If w ...

Vocabulary

Carnegie Mellon, LECTURE 21373
Excerpt: ... LaGrange Interpolation Polynomials Common Divisor Greatest Common Divisor Linear Combination Irreducible Euclidean Algorithm ...

claw070921

SUNY Albany, MAT 326
Excerpt: ... Classical Algebra Written Assignment No. 1 due Friday, September 21, 2007 Directions Written assignments must be typeset. While it is neither necessary nor desirable to show small details of computation, you must indicate what you are doing, give major steps in computation, and explain any reasoning used. Accuracy is important. With 5 problems in an assignment worth 10 points, there is limited room for partial credit on a problem. Problems 1. Let d denote the greatest common divisor of the integers 6545 and 3003. Find integers x, y such that 6545x + 3003y = d . 2. Find the least common multiple of 3003 and 6545. 3. Find the continued fraction expansion of the rational number 6545/3003. 4. Decompose 68815845 into prime factors. 5. Write a proof of the following: If a and b are positive integers and d the greatest common divisor of a and b, then every common divisor of a and b is a divisor of d. Note: Before undertaking this task, take careful note of the denitions of common divisor and greatest common div ...

claw060926

SUNY Albany, MAT 326
Excerpt: ... Classical Algebra Written Assignment No. 1 due Tuesday, September 26, 2006 Directions Written assignments must be typeset. While it is neither necessary nor desirable to show small details of computation, you must indicate what you are doing, give major steps in computation, and explain any reasoning used. Accuracy is important. With 5 problems in an assignment worth 5 points, there will be no room for partial credit on a problem. If you are in the writing intensive division of the course, you must complete each written assignment in a satisfactory way. This may require re-submission, possibly more than once, after the initial evaluation. Problems 1. Let d denote the greatest common divisor of the integers 2313 and 2235. Find integers x, y such that 2313x + 2235y = d . 2. Find the least common multiple of 2235 and 2313. 3. Find the continued fraction expansion of the rational number 2313/2235. 4. Decompose 301557375 into prime factors. 5. Write a proof of the following: If a and b are positive integers and ...

claw080916

SUNY Albany, MAT 326
Excerpt: ... Classical Algebra Written Assignment No. 1 due Tuesday, September 16, 2008 Directions Written assignments must be typeset. While it is neither necessary nor desirable to show small details of computation, you must indicate what you are doing, give major steps in computation, and explain any reasoning used. Accuracy is important. With 5 problems in an assignment worth 10 points, there is limited room for partial credit on a problem. Problems 1. Let d denote the greatest common divisor of the integers 6545 and 3003. Find integers x, y such that 6545x + 3003y = d . 2. Find the least common multiple of 3003 and 6545. 3. Find the continued fraction expansion of the rational number 6545/3003. 4. Decompose 68815845 into prime factors. 5. Write a proof of the following: If a and b are positive integers and d the greatest common divisor of a and b, then every common divisor of a and b is a divisor of d. Note: Before undertaking this task, take careful note of the definitions of common divisor and greatest common div ...

gcd

Rutgers, CS 205
Excerpt: ... Partial Correctness of GCD Matthew Stone Review Lecture April 2004 These notes tie together the course material weve done so far: logic, functions, numbers and induction. Well be studying the following computer program, called GCD: procedure gcd(a,b) x := a y := b while y = 0 begin r := x mod y x := y y := r end We will assume that all the variables a, b, x and y must take integer values. We also assume that a and b are positive and that a b. So our initial assertion about this program will be: ab>0 The nal assertion, meanwhile, just says x = gcd(a, b) In other words, when the loop terminates, x is the greatest common divisor of a and b. We will show that when the initial statement is true and we run GCD, the nal assertion becomes true. Lets review division and the logical ideas behind the greatest common divisor . 1. If a is a positive integer and b is an integer, we say that a divides b, or a is a divisor of b, if there is an integer c such that ac = b. We indicate that a divides b with ...

Class15

Pittsburgh, CS 441
Excerpt: ... CS 441 Discrete Mathematics for CS Lecture 15 Integers and division Milos Hauskrecht milos@cs.pitt.edu 5329 Sennott Square CS 441 Discrete mathematics for CS M. Hauskrecht Course administration Homework set 5 is out Due on Friday, February 24 , 2006 Course web page: http:/www.cs.pitt.edu/~milos/courses/cs441/ CS 441 Discrete mathematics for CS M. Hauskrecht 1 Division Let a be an integer and d a positive integer. Consider the task a/d . Then there are unique integers, q and r, with 0 <= r < d, such that a = dq + r. Definitions: a is called the dividend, d is called the divisor, q is called the quotient and r the remainder of the division. Relations: q = a div d , r = a mod d CS 441 Discrete mathematics for CS M. Hauskrecht Greatest common divisor Definition: Let a and b are integers, not both 0. Then the largest integer d such that d | a and d | b is called the greatest common divisor of a and b. The greatest common divisor is denoted as gcd(a,b). Examples: gcd(24,36) ...

MarsBar

Allan Hancock College, MATH 3065
Excerpt: ... THE MARS BAR CHALLENGE Problem 1 The proof of the last Theorem in the Turing Machine section of the notes was left as an exercise (see page 49). Give the proof! That is, prove that the set {n IN | n is a total function} is neither a recursively enumerable set, nor the complement of a recursively enumerable set. Problem 2 Express z = xy in FOPA (x, y and z being FOPA terms). [The problem is that while it is easy to express in FOPA the general term of an AP (Arithmetic Progression) u, u + v, u + 2v, . . . , it is not so easy to express in FOPA the general term of a GP (Geometric Progression) such as 1, x, x2 , . . . .] Hints: Is it true that, for any natural numbers m and n, there exists an AP of n natural numbers which all exceed m and which are pairwise relatively prime (that is, any two of them have greatest common divisor 1)? Given n natural numbers a0 , . . . , an1 , and a set of n pairwise relativly prime numbers b0 , . . . , bn1 with bi > ai for all i, does there exist a number w such that ...

Study3

Iowa State, CPRE 310
Excerpt: ... Cpr E 310 Spring 1999, Russell d:\.\cpre310\fall99\study\study3.wp6 STUDY GUIDE FOR EXAM-3 November 11, 1999 Topics to be covered will be Lecture and Problem topics in Sections 2.3, 2.4, and 2.6 (to and including Boolean Matrices. The exam will also cover modular arithmetic again). Exam problems may also be based on assigned homework. TOPICS: Division Algorithm Greatest Common Divisor Euclidean Algorithm Least Common Multiple Relatively Prime Modular Arithmetic (again) Cryptology Number Bases Twos Complement notation STUDY METHOD Review all topics given in lectures. Work other homework problems in the topic areas. Practice matrix operations. Study the boolean operations given in class. Practice Twos complement. Matrix add multiply minor cofactor adjoint transpose inverse Boolean Matrix Join Meet Boolean Product Coding Example Boolean matrix Hamming (7,4) code Page 1 ...

Math310HW4a

Washington, MATH 310
Excerpt: ... Math 310 Assignment 4a DUE NEVER, but you must do these before Exam 2 PROBLEMS: 6.7-6.9, 6.4, 6.17, 6.28 HOMEWORK NOTES/HINTS 6.7-6.9 are computational exercises to give you practice with the division and Euclidean algorithms. 6.4, 6.17, and 6.28 will give you practice with the greatest common divisor function. You might also try 6.1-6.3 to check that you understand the definitions ...

Vocabulary

Carnegie Mellon, LECTURE 21373
Excerpt: ... Division algorithm Quotient Remainder Divisor Multiple Common divisor Greatest common divisor Linear combination (a divides b) ...

Lecture02nt09

Allan Hancock College, MATH 3062
Excerpt: ... is not large in the scheme of things. Not having helped us solve our problem, I want to change the subject. Greatest Common Divisor s Let's consider two numbers, say 100 and 144. It is important that the numbers chosen have a reasonable number of common divisors, but that the Euclidean Algorithm applies in more than 2 steps. Let's write down the divisors of each number: 100 : 1 2 4 5 10 20 25 50 100 144 : 1 2 3 4 6 8 9 12 16 18 24 36 48 72 144 The student can easily see that the common divisors, which we can circle in the above array have a unique greatest one, which we call the Greatest Common Divisor . So the greatest common divisor of 100 and 144 is 4 and we write 4 = (100, 144). Now the above process will always work for any two numbers. The Greatest Common Divisor is a curious concept in mathematics in that it is defined by its name. It is the greatest of all the common divisors. The suggested method is however very definitely not a practical approach to the calculation of the greatest common divisor . T ...

gcd

Cincinnati, C 112
Excerpt: ... GreatestCommonDivisor m=385 n=294 GreatestCommonDivisor 385 =1R91 294 GreatestCommonDivisor 385 =1R91inotherwordsweneedgcdof 294 91+294and294 GreatestCommonDivisor 385 =1R91inotherwordsweneedgcdof 294 91+294and294 Butthisisthesameasthegcdof 91and2 ...