Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
The Integers and Division Division If a and b are integers with a 0, we say that a divides b if there is an integer c such that b =a c. When a divides b we say that a is a factor of b and that b is a multiple of a. The notation a|b denotes that a divides b. Example: Determine whether 3|7 and whether 3|12. Example: Let n and d be positive integers. How many positive integers not exceeding n are divisible by d? Theorem: Let a, b, c be integers. Then (i) If a|b and a|c then a|(b+c) (ii) If a|b then a|bc for all integers c (iii) If a|b and b|c then a|c Corollary: If a, b and c are integers such that a|b and a|c, then a|mb+nc whenever m and n are integers. The division algorithm Theorem: Let a be an integers and d a positive integer. Then there are unique integers q and r, with 0=<r<d such that a=dq+r. Definition: In the equality given in the division algorithm, d is called the divisor, a is called the dividend, q is called the quotient, and r is called the remainder. This notation is used to express the quotient and remainder: q=a div d, r=a mod d Example: What are the quotient and remainder when 101 is divided by 11? What are the quotient and remainder when -11 is divided by 3? Modular Arithmetic Definition: If a and b are integers and m is a positive integer, then a is congruent to b modulo m if m divides a-b. We use the notation a ´ b (mod m) to indicate that a is congruent to b modulo m. Theorem: Let a and b be integers, and let m be a positive integer. The a ´ b (mod m) if and only if a mod m = b mod m. Example: Determine whether 17 is congruent to 5 modulo 6 and whether 24 and 14 are congruent modulo 6. Theorem: Let m be a positive integer. The integers a and b are congruent modulo m if and only if there is an integer k such that a=b+km. Theorem: Let m be a positive integer. If a ´ b (mod m) and c ´ d (mod m), then a+c ´ b+d (mod m) and ac ´ bd (mod m) Corollary: Let m be a positive integer and let a and b be integers. Then (a+b) mod m = ((a mod m)+(b mod m)) mod m And Ab mod m = ((a mod m)(b mod m)) mod m. Applications of Congruences Hashing Functions: The central computer at an insurance company maintains records for each of its customers. How can memory locations be assigned so that customer records can be retrieved quickly? The solution to this problem is to use a suitably chosen hashing function. Records are identified using a key, which uniquely identifies each customer’s record. For instance Social Security number. In practice, many different hashing functions are used. One of the most common is the function h(k) = k mod m Where m is the number of available memory locations. Hash functions should be easily evaluated so that files can be quickly located. H(064212848) = 064212848 mod 111 = 14 H(037149212)= 037149212 mod 111 = 65 H(107405723)= 107405723 mod 111 = 14 But this location has been already occupied. However memory location 15, the first location following memory location 14 is free Pseudorandom Number Randomly chosen numbers are often needed for computer simulations. Different methods have been devised for generating numbers that have properties of randomly chosen numbers. Because numbers generated by systematic methods are not truly random they are called pseudorandom numbers. The most commonly used procedure for generating pseudorandom numbers is the linear congruential method. Xn+1 = (a xn +c) mod m