Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number

Size: px
Start display at page:

Download "Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number"

Transcription

1 Topic Contents Factoring Methods Unit 3 The smallest divisor of an integer The GCD of two numbers Generating prime numbers Computing prime factors of an integer Generating pseudo random numbers Raising a number to a large power Problem Given a number m devise an algorithm to compute its square root. Algorithm Description Let us understand what is meant by square root of a number. Taking specific examples we know that the square root of 4 is 2, square root of 9 is 3 and the square root of 16 is 4 and so on. That is From these examples we can conclude that in general case the square root on n, of a another number m must satisfy the equation n x n = m (1) Suppose, for example, we do not know the square root of 36. We might guess that 9 could be its square root. Using equation (1) to check our guess we find that 9X 9 = 81 which is greater than 36. Our guess of 9 is too high so we might next try 8. For example, 8x 8 = 64 which is still greater than 36 but closer than our original guess. 1

2 The investigation we have made suggests that we could adopt the following systematic approach to solve the problem. Choose a number n less than the number m we want the square of. Square n and if it is greater than m decrease n by 1 and repeat step 2, else go to step 3. When the square of our guess at the square root is less than m we can start increasing n by 0.1 until we again compute a guess greater than m. At this point, we start decreasing our guess by 0.01 and so on until we have computed the square root we require to the desired accuracy. In above algorithm the number of iterations required depends critically on how good our initial guess is (e.g. if m is 10,000 and our initial guess n is 500 we will need over 400 iterations). To try to make a better algorithm, let us again to the problem of finding the square root of 36, we found that If 9 divides into 36 to give 4. If we choose 4 as our square root candidate, we would have found. In other words, the 9 and the 4 tend to cancel out each other by deviating from the square m in opposite directions. Thus, We find that = which is greater than 36. Dividing this into 36: The square root of 36 must lie somewhere between 9, which is too big and 4, which is too small. Taking the average of 9 and 4: we see that it again has a complementary value (i.e. 5.53) that is less than 36. Thus If we are still unsure as to what to do next, we can take a guess at the square root and then use the equation (1) to check whether or not we have guessed correctly. For example: Suppose we don t know the square root of 36. We might guess that 9 could be the square root. Using equation 1 we find that 9 x 9 = 81 which is greater than 36. Another guess like 8 will result to 8 x 8 = 64 which is again greater than 36 but closer than the previous result. We now have two estimates of the square root, one on either side, that are closer than our first two estimates. We can proceed to get an even better estimate of the square root by averaging these two most recent guesses: Where = which is only slightly greater than the square we are seeking. However, we will assume that it is a good strategy and the development of the algorithm. 2

3 To perform the average of g1 and g2 is Algorithm Description To achieve this repetitive interchanging of roles by setting up the following loop We can therefore terminate the algorithm when the difference between g1 and g2 becomes less than some fixed error ( eg: ). This absolute difference is our termination condition. Algorithm ch03pg01.txt Problem Given an integer n devise and algorithm that we will find its smallest exact divisor other than one. Algorithm Development Taken a face value this problems seems to be trivial. We can take the set of numbers 2,4,6,.,n and divide each one in turn into n. As soon as we encounter a number in the set that exactly divides into n our algorithm can terminate as we have found the smallest exact divisor of n. All this looks very cool and straight. Now say suppose n is a prime number. May be n is a very large prime number (1013). So are we going to count all the way upto 1012 starting from 2 and check whether 1013 gets divided by any one of these numbers on the way? That sounds little stupid and requires a lot of work. 3

4 As a starting point for this investigation let us work out and examine the complete set of divisors for a particular number. Choosing the number 36 as our example, we find that its complete set of divisors are {2,3,4,6,9,12,18} We know that an exact divisor of a number divides into that number leaving no remainder. For example we require 9 fours to get 36. It also follows that the bigger number 9 also divides exactly into 36. That is Similarly if we choose the divisor 3, we find that it tells us that there is a bigger number 12 that is also an exact divisor of a number. For our complete set of divisors of 36, we see that: Or in other words, we want an s and b that satisfy. From this set, we see that the smallest divisor (2) is linked with the largest divisor (18), the second smallest divisor (3) is linked with the second largest divisor (12) and so on. From the above logic we can see that The smaller factor s The bigger factor b and or which s is less than b. The crossover point and limiting value must occur when s=b, i.e. when It follows that it is not necessary to look for smaller divisors of n that are greater than the square root of n. So lets review our design again. We know that all even numbers are divisible by 2. It follows that is the number we are testing is not divisible by 2 then it certainly will not be divisible by 4,6,8,10,. If the number we are testing is odd, we need to only consider odd number as potential smallest divisor. The overall strategy for out algorithm can be summarized : If the number n is even then the smallest divisor is 2. Else Compute the square root r of n. While no exact divisor less than square root of n do Test next divisor in sequence 3,5,7, All that is left to do now is work out the implementation details The divisors to test can be generated by starting d at 3 and using 4

5 To determine whether or not a number is an exact divisor of another number, we can check if there is any remainder after division. For this we use mod function. If n mod d = 0 then d is an exact divisor of n. The two conditions for termination can be n mod d = 0 and d>=r Algorithm Description Algorithm Smallestdivisor.txt Problem Given two positive non-zero n and m design an algorithm for finding their greatest common divisor (GCD). Algorithm Development Our first step might therefore be to break the problem down and find all the divisors of the two n and m independently. Once we have these two lists of divisors we soon realize that we must do is select the largest element common to both lists. This element must be the greatest common divisor for the two n and m. We may expect that this algorithm will be relatively time consuming for large values of n and m because of the tedious step of having to generate all factors of two. It was the Greek philosopher, Euclid, who more than 2000 years ago first published a better way to solve this problem. To embark our search for a better algorithm, a good place to start is with a careful look at just what is the greatest common divisor of two numbers. The gcd of two numbers is the largest integer that will divide exactly into the two with no remainder 5

6 So our basic strategy for computing the gcd of two numbers is: The mod function allows us to compute the remainder resulting from an integer division. We use: To try to formulate this construct, let us return to gcd(18,30) problem let us see the calculations Algorithm Description Algorithm gcd.txt Applications Reducing a fraction to its lowest terms. Problem Use the linear congruentaial method to generate a uniform set of pseudo random numbers. Algorithm Development Random number are frequently used in computing science for generators among other things, testing and analysing the behavior of algorithms. A sequence of random numbers should exhibit the following behavior. The sequence should appear as though each number had occurred by chance. Each number should have a specified probability of falling within a given range. 6

7 The approach generally taken in computing science for random number generation is to simulate random processes by producing a sequence of numbers that appear to exhibit random behavior. These sequences are predictable in advance and for this reason they are usually referred to as pseudorandom sequences. There are many methods for generating pseudorandom numbers. Perhaps the most widely used of these algorithms is the linear congruential method. When this method is appropriately parameterized it will generate pseudo-random sequences that, for practical purposes. The implementation of the linear congruential method is very straight-forward. Successive members of the linear congruential sequence {x} are generated using the expression: where the parameters a, b, m and x 0 must be carefully chosen in advance according to certain criteria. The parameters a, b, and m are referred to as the multiplier, increment, and modulus respectively. All parameters should be greater than or equal to zero and m should be greater than x 0,a and b. Parameter x 0 : The parameter x0 can be chosen arbitrarily within the range 0--x0<m. Parameter m: The value of m should e greater than or equal to the length of the random sequence required. In addition it must be possible to do the computation (a*x)+b mod m without roundoff. Parameter a: The choice of a depends on the choice of m. If m is a power of 2 then a should satisfy the condition: a mod 8 = 5 If m is a power of 10, then a should be chosen such that: a mod 200 = 21 Further requirements on a are that it should be larger than m and less than m- m, (a-1) should be a multiple of every prime dividing into m, and if m is a multiple of 4 then (a-1) should also be a multiple of 4. These conditions together with the requirements that b should relatively prime to m are needed to guarantee that the sequence has a period of m. Paramter b: The constant b should be odd and not a multiple of 5. When a, b, and m are chosen according to the conditions outlined above a sequence of m pseudo-random numbers in the range 0 to (m-1) can be generated before the sequence begins to repeat. Algorithm Algorithm for the linear congruential method is given below for an m value of Applications Analysis of algorithm Simulation problems and games 7

8 Problem Given some integer x, compute the value of xn where n is a positive integer considerably greater than 1. Algorithm Development Evaluating the expression p = x n here x and n are given is a straightforward task. A simple method of evaluation is to repeatedly multiply an accumulating product p by x for n iterations, for example, p := 1 for i := 1 to n do p := p*x In most cases, evaluating x n in this way is satisfactory. Let us therefore concern ourselves with trying to discover a more efficient algorithm for power evaluation. Consider the evaluation of x n. In our stepwise approach we have: Studying these steps carefully, we see that x is increasing by one power at each step. In trying to evaluate x 10 more efficiently, what are we really trying to do? To evaluate x 10 more efficiently implies that we will need to take fewer steps to complete the task. Looking back at our example, we see that we could have generated x 4 by simply multiplying x 2 by itself, for example, x 4 = x 2 x x 2 This requires just one multiplication rather than the two multiplications used in our example above. In terms of power addition we have 2+2 = 4 compared with 2+1+1= 4. In one sense, what this most recent example tells us is that we will have solved our problem in the most efficient way when we discover the set of numbers that add to 10 in the least number of steps. Some sets of numbers that add up to 10 are: What we observe is that one of these possibilities we choose must solve the problem more efficiently. Suppose we choose 8 and 2 as our pair of powers to generate x 10 (i.e. x 8 * x 2 = x 10 ). We need to ask what is the "smallest" pair of numbers that we can choose that we can choose that add up to 10? The answer to this question has to be two 5 s. To generate x 5 we square x 2 to give x 4 and then multiplying that result with x. 8

9 The steps to compute x 10 are therefore: With this scheme we have used only four rather than nine multiplications to evaluate x 10 We can try the same idea with second example: Here we can see that only 7 multiplications have been required to raise a number to the power 23. At each stage in the power generation process, one of two conditions apply: When we have an odd power it must have been generated from the power that is one less (eg: x 23 = x 22 * x). Where we have an even power, it can be computed from a power that is half its size (e.g. x 22 = x 11 * x 11 ). These last two statements capture the essence of the algorithm. This means that our algorithm will need to be in two parts: a part that determines the multiplication strategy, and that does the a second part actually power evaluation. To map out the multiplication procedure, we can start with the power required and determine whether it is even or odd. The next step is to integer-divide the current power by 2 and repeat the even/odd determination procedure. For example for x 23 we would have : To carry out the second of the algorithm (i.e. the power evaluation part), we need to work forwards rather than backwards. Which means we must start with the highest element in the d array (in our example d[4]) and work back down to d[1]. Starting out with our product p equal to 1 we can proceed with the power evaluation using the following rule: if the current d array element is zero then (a) we simply square the current power product p, else (a') we square the current product p and multiply by x to generate an odd power. For the evaluation of x 23 the steps are: Referring to the binary representation for x23 we see that it can be written as We can generate binary representation of a number by dividing the power n by 2. For example the binary representation of 23 is : Which suggests that power evaluation can be coupled directly with binary representation of the power of n. 9

10 Each of these powers can be generated by multiplying its predecessors by itself For example: Studying the example once again we see that power evaluation involves the following steps. Successive generation of numbers of the power sequence Inclusion of the current power member into the accumulated product when the corresponding binary digit is one. Table below summarizes the power evaluation for x 23 by our new proposal. The test n mod 2 = 1 can be used to check if the next most significant binary digit is one. If the total product is named product and the power sequences are named psequences then to store the current power we use the following standard form: The variable product will initially will be set to 1. The power sequence variable psequence will need to be initialized to x. With successive iterations the power value of psequence will need to be doubled. This can be accomplished by using The other step that must take place with each iteration is that n must be divided by 2. For example: The algorithm must terminate when n is reduced to zero. Algorithm Description 1. Establish n, the integer power, and x the integer to be raised to the power n. 2. Initialize the power sequence and product variable for the zero power case. 3. While the power n is greater than zero do 1. if next most significant binary digit of power n is one then multiply by current sequence accumulated product power value; 2. reduce power n by a factor of two using integer division; 3. get next power sequence member by multiplying current value by itself. 4. Return x raised to the power n. Algorithm Applications Encryption (secret coding of information), And testing for non-primary of numbers 10

11 Problem Given a number n generate the n th member of the Fibonacci sequence. Algorithm development Remembering back to algorithm (2.6) we are given that the n th member of the Fibonacci sequence f n is defined recursively as follows: We have previously seen how this definition can be used in conjunction with an iterative construct to generate Fibonacci numbers. What we are concerned with here is whether or not there is a more efficient way of generating the n th Fibonacci number rather than the complete sequence of n Fibonacci numbers. It sometimes happens when one member of a set is required the job can be done more efficiently than generating the (n 1) predecessors. In the power generation problem, our task was straightforward because the relationship between powers of i and the powers of 2i was simple and easily defined (e.g. x 6 = x 3 * x 3 ). In our present problem we are not sure whether such a "doubling relationship exists. To explore this possibility let us write down the first few members of the Fibonacci sequence. Here we can try is some combination of two Fibonacci numbers to generate the "doubled' Fibonacci number. This might have more chance of success since in the original problem for generating Fibonacci numbers, two numbers are used to generate the next. Let us therefore try to write f8 in terms of only f4 and f5. To do this we will need to use the original definition for the sequence. That is Checking with f 10, f 5 and f 6 to see if the formula generalizes, we get Without going into a detailed proof, we might be satisfied that in general: Collecting terms we get Since f 5 = 3 and f 4 = 2 the last expression suggests: To generate the f 2n+1 Fibonacci number we need f 2n and f 2n-1 11

12 The problem is we do not have f 2n-1 and so we are not much better off. Therefore we to do this in previous example we need to generate f 9 from f 5 and f 4. Applying the same substitution method as we used to establish: after some substitution and checking, we finally get: We now have the basis of a method for generating the n th Fibonacci number in a similar manner to raising x to the power n as in algorithm (3.7). In this case our algorithm will need to be in two parts: a part that determines the doubling strategy by generating the binary representation of n and a second part that actually computes the nth Fibonacci number according to the doubling strategy. Algorithm description Algorithm nthfibonacci.txt 12

Math 016 Lessons Wimayra LUY

Math 016 Lessons Wimayra LUY Math 016 Lessons Wimayra LUY wluy@ccp.edu MATH 016 Lessons LESSON 1 Natural Numbers The set of natural numbers is given by N = {0, 1, 2, 3, 4...}. Natural numbers are used for two main reasons: 1. counting,

More information

You separate binary numbers into columns in a similar fashion. 2 5 = 32

You separate binary numbers into columns in a similar fashion. 2 5 = 32 RSA Encryption 2 At the end of Part I of this article, we stated that RSA encryption works because it s impractical to factor n, which determines P 1 and P 2, which determines our private key, d, which

More information

Some Facts from Number Theory

Some Facts from Number Theory Computer Science 52 Some Facts from Number Theory Fall Semester, 2014 These notes are adapted from a document that was prepared for a different course several years ago. They may be helpful as a summary

More information

8 Primes and Modular Arithmetic

8 Primes and Modular Arithmetic 8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.

More information

The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.

The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem. CS 70 Discrete Mathematics for CS Fall 2003 Wagner Lecture 10 The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.

More information

22. The Quadratic Sieve and Elliptic Curves. 22.a The Quadratic Sieve

22. The Quadratic Sieve and Elliptic Curves. 22.a The Quadratic Sieve 22. The Quadratic Sieve and Elliptic Curves 22.a The Quadratic Sieve Sieve methods for finding primes or for finding factors of numbers are methods by which you take a set P of prime numbers one by one,

More information

11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic

11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic 11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic Bezout s Lemma Let's look at the values of 4x + 6y when x and y are integers. If x is -6 and y is 4 we

More information

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5 CS 70 Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5 Modular Arithmetic In several settings, such as error-correcting codes and cryptography, we sometimes wish to work over a

More information

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers ALGEBRA CHRISTIAN REMLING 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers by Z = {..., 2, 1, 0, 1,...}. Given a, b Z, we write a b if b = ac for some

More information

Integers and Division

Integers and Division Integers and Division Notations Z: set of integers N : set of natural numbers R: set of real numbers Z + : set of positive integers Some elements of number theory are needed in: Data structures, Random

More information

Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6

Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6 CS 70 Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6 1 Modular Arithmetic In several settings, such as error-correcting codes and cryptography, we sometimes

More information

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer? Chapter 3: Theory of Modular Arithmetic 25 SECTION C Solving Linear Congruences By the end of this section you will be able to solve congruence equations determine the number of solutions find the multiplicative

More information

Math 131 notes. Jason Riedy. 6 October, Linear Diophantine equations : Likely delayed 6

Math 131 notes. Jason Riedy. 6 October, Linear Diophantine equations : Likely delayed 6 Math 131 notes Jason Riedy 6 October, 2008 Contents 1 Modular arithmetic 2 2 Divisibility rules 3 3 Greatest common divisor 4 4 Least common multiple 4 5 Euclidean GCD algorithm 5 6 Linear Diophantine

More information

Algebra Introduction to Polynomials

Algebra Introduction to Polynomials Introduction to Polynomials What is a Polynomial? A polynomial is an expression that can be written as a term or a sum of terms, each of which is the product of a scalar (the coefficient) and a series

More information

Fibonacci mod k. In this section, we examine the question of which terms of the Fibonacci sequence have a given divisor k.

Fibonacci mod k. In this section, we examine the question of which terms of the Fibonacci sequence have a given divisor k. Fibonacci mod k I start by giving out a table of the first 0 Fibonacci numbers actually the first, because we begin with u 0 =0 (and I have a reason for that which will soon become apparent). Okay, which

More information

FERMAT S TEST KEITH CONRAD

FERMAT S TEST KEITH CONRAD FERMAT S TEST KEITH CONRAD 1. Introduction Fermat s little theorem says for prime p that a p 1 1 mod p for all a 0 mod p. A naive extension of this to a composite modulus n 2 would be: for all a 0 mod

More information

Some Review Problems for Exam 1: Solutions

Some Review Problems for Exam 1: Solutions Math 3355 Fall 2018 Some Review Problems for Exam 1: Solutions Here is my quick review of proof techniques. I will focus exclusively on propositions of the form p q, or more properly, x P (x) Q(x) or x

More information

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer? Chapter 3: Theory of Modular Arithmetic 25 SECTION C Solving Linear Congruences By the end of this section you will be able to solve congruence equations determine the number of solutions find the multiplicative

More information

CS 360, Winter Morphology of Proof: An introduction to rigorous proof techniques

CS 360, Winter Morphology of Proof: An introduction to rigorous proof techniques CS 30, Winter 2011 Morphology of Proof: An introduction to rigorous proof techniques 1 Methodology of Proof An example Deep down, all theorems are of the form If A then B, though they may be expressed

More information

Elementary Properties of the Integers

Elementary Properties of the Integers Elementary Properties of the Integers 1 1. Basis Representation Theorem (Thm 1-3) 2. Euclid s Division Lemma (Thm 2-1) 3. Greatest Common Divisor 4. Properties of Prime Numbers 5. Fundamental Theorem of

More information

Topics in Computer Mathematics

Topics in Computer Mathematics Random Number Generation (Uniform random numbers) Introduction We frequently need some way to generate numbers that are random (by some criteria), especially in computer science. Simulations of natural

More information

Lecture 6: Introducing Complexity

Lecture 6: Introducing Complexity COMP26120: Algorithms and Imperative Programming Lecture 6: Introducing Complexity Ian Pratt-Hartmann Room KB2.38: email: ipratt@cs.man.ac.uk 2015 16 You need this book: Make sure you use the up-to-date

More information

MAT 243 Test 2 SOLUTIONS, FORM A

MAT 243 Test 2 SOLUTIONS, FORM A MAT 24 Test 2 SOLUTIONS, FORM A 1. [1 points] Prove the following using Mathematical Induction. L 2 i = L n L n+1 + 2 where L is the Lucas sequence: L 0 = 2 L 1 = 1 L n = L n 1 + L n 2, n 2 Solution: Let

More information

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}. 2 Arithmetic This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}. (See [Houston, Chapters 27 & 28]) 2.1 Greatest common divisors Definition 2.16. If a, b are integers, we say

More information

Fall 2017 Test II review problems

Fall 2017 Test II review problems Fall 2017 Test II review problems Dr. Holmes October 18, 2017 This is a quite miscellaneous grab bag of relevant problems from old tests. Some are certainly repeated. 1. Give the complete addition and

More information

19. Coding for Secrecy

19. Coding for Secrecy 19. Coding for Secrecy 19.1 Introduction Protecting sensitive information from the prying eyes and ears of others is an important issue today as much as it has been for thousands of years. Government secrets,

More information

Direct Proof MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Direct Proof Fall / 24

Direct Proof MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Direct Proof Fall / 24 Direct Proof MAT231 Transition to Higher Mathematics Fall 2014 MAT231 (Transition to Higher Math) Direct Proof Fall 2014 1 / 24 Outline 1 Overview of Proof 2 Theorems 3 Definitions 4 Direct Proof 5 Using

More information

Grade 8 Chapter 7: Rational and Irrational Numbers

Grade 8 Chapter 7: Rational and Irrational Numbers Grade 8 Chapter 7: Rational and Irrational Numbers In this chapter we first review the real line model for numbers, as discussed in Chapter 2 of seventh grade, by recalling how the integers and then the

More information

Number Theory. Introduction

Number Theory. Introduction Number Theory Introduction Number theory is the branch of algebra which studies the properties of the integers. While we may from time to time use real or even complex numbers as tools to help us study

More information

Chapter 1 Review of Equations and Inequalities

Chapter 1 Review of Equations and Inequalities Chapter 1 Review of Equations and Inequalities Part I Review of Basic Equations Recall that an equation is an expression with an equal sign in the middle. Also recall that, if a question asks you to solve

More information

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time. 8 Modular Arithmetic We introduce an operator mod. Let d be a positive integer. For c a nonnegative integer, the value c mod d is the remainder when c is divided by d. For example, c mod d = 0 if and only

More information

CLASS-IX MATHEMATICS. For. Pre-Foundation Course CAREER POINT

CLASS-IX MATHEMATICS. For. Pre-Foundation Course CAREER POINT CLASS-IX MATHEMATICS For Pre-Foundation Course CAREER POINT CONTENTS S. No. CHAPTERS PAGE NO. 0. Number System... 0 3 0. Polynomials... 39 53 03. Co-ordinate Geometry... 54 04. Introduction to Euclid's

More information

Intermediate Math Circles February 26, 2014 Diophantine Equations I

Intermediate Math Circles February 26, 2014 Diophantine Equations I Intermediate Math Circles February 26, 2014 Diophantine Equations I 1. An introduction to Diophantine equations A Diophantine equation is a polynomial equation that is intended to be solved over the integers.

More information

Lecture 12 : Recurrences DRAFT

Lecture 12 : Recurrences DRAFT CS/Math 240: Introduction to Discrete Mathematics 3/1/2011 Lecture 12 : Recurrences Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last few classes we talked about program correctness. We

More information

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013 Fall 2013 Student Responsibilities Reading: Textbook, Section 3.7, 4.1, & 5.2 Assignments: Sections 3.6, 3.7, 4.1 Proof Worksheets Attendance: Strongly Encouraged Overview 3.6 Integers and Algorithms 3.7

More information

Mathematics of Cryptography

Mathematics of Cryptography Modulo arithmetic Fermat's Little Theorem If p is prime and 0 < a < p, then a p 1 = 1 mod p Ex: 3 (5 1) = 81 = 1 mod 5 36 (29 1) = 37711171281396032013366321198900157303750656 = 1 mod 29 (see http://gauss.ececs.uc.edu/courses/c472/java/fermat/fermat.html)

More information

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd()

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd() Student Responsibilities Week 8 Mat 2345 Week 8 Reading: Textbook, Section 3.7, 4.1, & 5.2 Assignments: Sections 3.6, 3.7, 4.1 Induction Proof Worksheets Attendance: Strongly Encouraged Fall 2013 Week

More information

Section 4. Quantitative Aptitude

Section 4. Quantitative Aptitude Section 4 Quantitative Aptitude You will get 35 questions from Quantitative Aptitude in the SBI Clerical 2016 Prelims examination and 50 questions in the Mains examination. One new feature of the 2016

More information

1 Modular Arithmetic Grade Level/Prerequisites: Time: Materials: Preparation: Objectives: Navajo Nation Math Circle Connection

1 Modular Arithmetic Grade Level/Prerequisites: Time: Materials: Preparation: Objectives: Navajo Nation Math Circle Connection 1 Modular Arithmetic Students will explore a type of arithmetic that results from arranging numbers in circles instead of on a number line. Students make and prove conjectures about patterns relating to

More information

Chapter 1 A Survey of Divisibility 14

Chapter 1 A Survey of Divisibility 14 Chapter 1 A Survey of Divisibility 14 SECTION C Euclidean Algorithm By the end of this section you will be able to use properties of the greatest common divisor (gcd) obtain the gcd using the Euclidean

More information

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications n-bit unsigned integer representation Represent integer x as sum of powers of 2: If x = n 1 i=0 b i 2 i where each b i

More information

Adam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course

Adam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course Adam Blank Spring 2017 CSE 311 Foundations of Computing I * All slides are a combined effort between previous instructors of the course HW 3 De-Brief HW 3 De-Brief PROOFS! HW 3 De-Brief Proofs This is

More information

Math From Scratch Lesson 28: Rational Exponents

Math From Scratch Lesson 28: Rational Exponents Math From Scratch Lesson 28: Rational Exponents W. Blaine Dowler October 8, 2012 Contents 1 Exponent Review 1 1.1 x m................................. 2 x 1.2 n x................................... 2 m

More information

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by SUBGROUPS OF CYCLIC GROUPS KEITH CONRAD 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by g = {g k : k Z}. If G = g, then G itself is cyclic, with g as a generator. Examples

More information

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications casting out 3s Theorem: A positive integer n is divisible by 3 if and only if the sum of its decimal digits is divisible

More information

Number Theory and the abc Conjecture

Number Theory and the abc Conjecture Number Theory is the study of integers. Common topics include prime numbers, divisors and multiples, modular arithmetic, and Diophantine equations (equations in which we re looking for integer solutions).

More information

4.5 Applications of Congruences

4.5 Applications of Congruences 4.5 Applications of Congruences 287 66. Find all solutions of the congruence x 2 16 (mod 105). [Hint: Find the solutions of this congruence modulo 3, modulo 5, and modulo 7, and then use the Chinese remainder

More information

Number Theory. Modular Arithmetic

Number Theory. Modular Arithmetic Number Theory The branch of mathematics that is important in IT security especially in cryptography. Deals only in integer numbers and the process can be done in a very fast manner. Modular Arithmetic

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 9 February 6, 2012 CPSC 467b, Lecture 9 1/53 Euler s Theorem Generating RSA Modulus Finding primes by guess and check Density of

More information

Divisibility. Chapter Divisors and Residues

Divisibility. Chapter Divisors and Residues Chapter 1 Divisibility Number theory is concerned with the properties of the integers. By the word integers we mean the counting numbers 1, 2, 3,..., together with their negatives and zero. Accordingly

More information

Discrete Mathematics GCD, LCM, RSA Algorithm

Discrete Mathematics GCD, LCM, RSA Algorithm Discrete Mathematics GCD, LCM, RSA Algorithm Abdul Hameed http://informationtechnology.pk/pucit abdul.hameed@pucit.edu.pk Lecture 16 Greatest Common Divisor 2 Greatest common divisor The greatest common

More information

Algorithms (II) Yu Yu. Shanghai Jiaotong University

Algorithms (II) Yu Yu. Shanghai Jiaotong University Algorithms (II) Yu Yu Shanghai Jiaotong University Chapter 1. Algorithms with Numbers Two seemingly similar problems Factoring: Given a number N, express it as a product of its prime factors. Primality:

More information

HOW TO WRITE PROOFS. Dr. Min Ru, University of Houston

HOW TO WRITE PROOFS. Dr. Min Ru, University of Houston HOW TO WRITE PROOFS Dr. Min Ru, University of Houston One of the most difficult things you will attempt in this course is to write proofs. A proof is to give a legal (logical) argument or justification

More information

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers Number Theory: Applications Number Theory Applications Computer Science & Engineering 235: Discrete Mathematics Christopher M. Bourke cbourke@cse.unl.edu Results from Number Theory have many applications

More information

Introduction to Number Theory. The study of the integers

Introduction to Number Theory. The study of the integers Introduction to Number Theory The study of the integers of Integers, The set of integers = {... 3, 2, 1, 0, 1, 2, 3,...}. In this lecture, if nothing is said about a variable, it is an integer. Def. We

More information

Remainders. We learned how to multiply and divide in elementary

Remainders. We learned how to multiply and divide in elementary Remainders We learned how to multiply and divide in elementary school. As adults we perform division mostly by pressing the key on a calculator. This key supplies the quotient. In numerical analysis and

More information

Discrete Logarithm Problem

Discrete Logarithm Problem Discrete Logarithm Problem Çetin Kaya Koç koc@cs.ucsb.edu (http://cs.ucsb.edu/~koc/ecc) Elliptic Curve Cryptography lect08 discrete log 1 / 46 Exponentiation and Logarithms in a General Group In a multiplicative

More information

2.2 Inverses and GCDs

2.2 Inverses and GCDs 34 CHAPTER 2. CRYPTOGRAPHY AND NUMBER THEORY 2.2 Inverses and GCDs 2.2.1 Inverses mod p In the last section we explored the multiplication in Z n. We saw in the special case with n =12 and a = 4 that if

More information

CS March 17, 2009

CS March 17, 2009 Discrete Mathematics CS 2610 March 17, 2009 Number Theory Elementary number theory, concerned with numbers, usually integers and their properties or rational numbers mainly divisibility among integers

More information

Prime Analysis in Binary

Prime Analysis in Binary Prime Analysis in Binary Brandynne Cho Saint Mary s College of California September 17th, 2012 The best number is 73. [...] 73 is the 21st prime number. Its mirror, 37, is the 12th, and its mirror, 21,

More information

6.4 Division of Polynomials. (Long Division and Synthetic Division)

6.4 Division of Polynomials. (Long Division and Synthetic Division) 6.4 Division of Polynomials (Long Division and Synthetic Division) When we combine fractions that have a common denominator, we just add or subtract the numerators and then keep the common denominator

More information

download instant at

download instant at 2 CRYPTOGRAPHY AND NUMBER THEORY 2.1 CRYPTOGRAPHY AND MODULAR ARITHMETIC Pages 54 to 56 Problem 1 Problem 2 Problem 3 Problem 4 14 mod 9 = 5; 1 mod 9 = 8; 11 mod 9 = 7. KHUH LV D PHVVDJH. EBOB FP X JBPPXDB.

More information

WORKSHEET ON NUMBERS, MATH 215 FALL. We start our study of numbers with the integers: N = {1, 2, 3,...}

WORKSHEET ON NUMBERS, MATH 215 FALL. We start our study of numbers with the integers: N = {1, 2, 3,...} WORKSHEET ON NUMBERS, MATH 215 FALL 18(WHYTE) We start our study of numbers with the integers: Z = {..., 2, 1, 0, 1, 2, 3,... } and their subset of natural numbers: N = {1, 2, 3,...} For now we will not

More information

Commutative Rings and Fields

Commutative Rings and Fields Commutative Rings and Fields 1-22-2017 Different algebraic systems are used in linear algebra. The most important are commutative rings with identity and fields. Definition. A ring is a set R with two

More information

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points.

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points. Math 152, Problem Set 2 solutions (2018-01-24) All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points. 1. Let us look at the following equation: x 5 1

More information

that if a b (mod m) and c d (mod m), then ac bd (mod m) soyou aren't allowed to use this fact!) A5. (a) Show that a perfect square must leave a remain

that if a b (mod m) and c d (mod m), then ac bd (mod m) soyou aren't allowed to use this fact!) A5. (a) Show that a perfect square must leave a remain PUTNAM PROBLEM SOLVING SEMINAR WEEK 2 The Rules. You are not allowed to try a problem that you already know how to solve. These are way too many problems to consider. Just pick a few problems in one of

More information

Saturday, April 23, Dependence Analysis

Saturday, April 23, Dependence Analysis Dependence Analysis Motivating question Can the loops on the right be run in parallel? i.e., can different processors run different iterations in parallel? What needs to be true for a loop to be parallelizable?

More information

Algorithmic number theory. Questions/Complaints About Homework? The division algorithm. Division

Algorithmic number theory. Questions/Complaints About Homework? The division algorithm. Division Questions/Complaints About Homework? Here s the procedure for homework questions/complaints: 1. Read the solutions first. 2. Talk to the person who graded it (check initials) 3. If (1) and (2) don t work,

More information

Proof Techniques (Review of Math 271)

Proof Techniques (Review of Math 271) Chapter 2 Proof Techniques (Review of Math 271) 2.1 Overview This chapter reviews proof techniques that were probably introduced in Math 271 and that may also have been used in a different way in Phil

More information

Math 302 Module 4. Department of Mathematics College of the Redwoods. June 17, 2011

Math 302 Module 4. Department of Mathematics College of the Redwoods. June 17, 2011 Math 302 Module 4 Department of Mathematics College of the Redwoods June 17, 2011 Contents 4 Integer Exponents and Polynomials 1 4a Polynomial Identification and Properties of Exponents... 2 Polynomials...

More information

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory). Wednesday, February 21 Today we will begin Course Notes Chapter 5 (Number Theory). 1 Return to Chapter 5 In discussing Methods of Proof (Chapter 3, Section 2) we introduced the divisibility relation from

More information

Optimisation and Operations Research

Optimisation and Operations Research Optimisation and Operations Research Lecture 12: Algorithm Analysis and Complexity Matthew Roughan http://www.maths.adelaide.edu.au/matthew.roughan/ Lecture_notes/OORII/

More information

Loop Convergence. CS 536: Science of Programming, Fall 2018

Loop Convergence. CS 536: Science of Programming, Fall 2018 Solved Loop Convergence CS 536: Science of Programming, Fall 2018 A. Why Diverging programs aren t useful, so it s useful to know how to show that loops terminate. B. Objectives At the end of this lecture

More information

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Note 7

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Note 7 EECS 70 Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Note 7 Polynomials Polynomials constitute a rich class of functions which are both easy to describe and widely applicable in topics

More information

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime. PUTNAM TRAINING NUMBER THEORY (Last updated: December 11, 2017) Remark. This is a list of exercises on Number Theory. Miguel A. Lerma Exercises 1. Show that the sum of two consecutive primes is never twice

More information

Chapter 5. Number Theory. 5.1 Base b representations

Chapter 5. Number Theory. 5.1 Base b representations Chapter 5 Number Theory The material in this chapter offers a small glimpse of why a lot of facts that you ve probably nown and used for a long time are true. It also offers some exposure to generalization,

More information

Algebra Exam. Solutions and Grading Guide

Algebra Exam. Solutions and Grading Guide Algebra Exam Solutions and Grading Guide You should use this grading guide to carefully grade your own exam, trying to be as objective as possible about what score the TAs would give your responses. Full

More information

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography David R. Wilkins Copyright c David R. Wilkins 2000 2013 Contents 9 Introduction to Number Theory 63 9.1 Subgroups

More information

CDM. Recurrences and Fibonacci

CDM. Recurrences and Fibonacci CDM Recurrences and Fibonacci Klaus Sutner Carnegie Mellon University 20-fibonacci 2017/12/15 23:16 1 Recurrence Equations Second Order The Fibonacci Monoid Recurrence Equations 3 We can define a sequence

More information

CHAPTER 1 NUMBER SYSTEMS. 1.1 Introduction

CHAPTER 1 NUMBER SYSTEMS. 1.1 Introduction N UMBER S YSTEMS NUMBER SYSTEMS CHAPTER. Introduction In your earlier classes, you have learnt about the number line and how to represent various types of numbers on it (see Fig..). Fig.. : The number

More information

Number Systems III MA1S1. Tristan McLoughlin. December 4, 2013

Number Systems III MA1S1. Tristan McLoughlin. December 4, 2013 Number Systems III MA1S1 Tristan McLoughlin December 4, 2013 http://en.wikipedia.org/wiki/binary numeral system http://accu.org/index.php/articles/1558 http://www.binaryconvert.com http://en.wikipedia.org/wiki/ascii

More information

Chapter 7. Number Theory. 7.1 Prime Numbers

Chapter 7. Number Theory. 7.1 Prime Numbers Chapter 7 Number Theory 7.1 Prime Numbers Any two integers can be multiplied together to produce a new integer. For example, we can multiply the numbers four and five together to produce twenty. In this

More information

CDM. Recurrences and Fibonacci. 20-fibonacci 2017/12/15 23:16. Terminology 4. Recurrence Equations 3. Solution and Asymptotics 6.

CDM. Recurrences and Fibonacci. 20-fibonacci 2017/12/15 23:16. Terminology 4. Recurrence Equations 3. Solution and Asymptotics 6. CDM Recurrences and Fibonacci 1 Recurrence Equations Klaus Sutner Carnegie Mellon University Second Order 20-fibonacci 2017/12/15 23:16 The Fibonacci Monoid Recurrence Equations 3 Terminology 4 We can

More information

Math 109 HW 9 Solutions

Math 109 HW 9 Solutions Math 109 HW 9 Solutions Problems IV 18. Solve the linear diophantine equation 6m + 10n + 15p = 1 Solution: Let y = 10n + 15p. Since (10, 15) is 5, we must have that y = 5x for some integer x, and (as we

More information

Projective space. There are some situations when this approach seems to break down; for example with an equation like f(x; y) =y 2 (x 3 5x +3) the lin

Projective space. There are some situations when this approach seems to break down; for example with an equation like f(x; y) =y 2 (x 3 5x +3) the lin Math 445 Handy facts since the second exam Don't forget the handy facts from the first two exams! Rational points on curves For more general curves, defined by polynomials f(x; y) = 0 of higher degree,

More information

1: Please compute the Jacobi symbol ( 99

1: Please compute the Jacobi symbol ( 99 SCORE/xx: Math 470 Communications Cryptography NAME: PRACTICE FINAL Please show your work write only in pen. Notes are forbidden. Calculators, all other electronic devices, are forbidden. Brains are encouraged,

More information

Clock Arithmetic and Euclid s Algorithm

Clock Arithmetic and Euclid s Algorithm Clock Arithmetic and Euclid s Algorithm Lecture notes for Access 2008 by Erin Chamberlain. Earlier we discussed Caesar Shifts and other substitution ciphers, and we saw how easy it was to break these ciphers

More information

21. Factoring Numbers I

21. Factoring Numbers I 21. Factoring Numbers I 1. Introduction The RSA type encoding can be broken if an intruder can factor the number N of its public key. We here describe some of the methods that people have devised for factoring

More information

Answers (1) A) 36 = - - = Now, we can divide the numbers as shown below. For example : 4 = 2, 2 4 = -2, -2-4 = -2, 2-4 = 2.

Answers (1) A) 36 = - - = Now, we can divide the numbers as shown below. For example : 4 = 2, 2 4 = -2, -2-4 = -2, 2-4 = 2. Answers (1) A) 36 We can divide the two numbers by using the following steps : 1. Firstly, we will divide the mathematical signs of the numbers. We place a negative sign before the negative numbers and

More information

SEVENTH EDITION and EXPANDED SEVENTH EDITION

SEVENTH EDITION and EXPANDED SEVENTH EDITION SEVENTH EDITION and EXPANDED SEVENTH EDITION Slide 5-1 Chapter 5 Number Theory and the Real Number System 5.1 Number Theory Number Theory The study of numbers and their properties. The numbers we use to

More information

Exam 2 Solutions. In class questions

Exam 2 Solutions. In class questions Math 5330 Spring 2018 Exam 2 Solutions In class questions 1. (15 points) Solve the following congruences. Put your answer in the form of a congruence. I usually find it easier to go from largest to smallest

More information

CS250: Discrete Math for Computer Science

CS250: Discrete Math for Computer Science CS250: Discrete Math for Computer Science L6: Euclid s Algorithm & Multiplicative Inverses Mod m Greatest Common Divisors, GCD If d a and d b then d is a common divisor of a and b. 1, 2, 3, and 6 are common

More information

Math 38: Graph Theory Spring 2004 Dartmouth College. On Writing Proofs. 1 Introduction. 2 Finding A Solution

Math 38: Graph Theory Spring 2004 Dartmouth College. On Writing Proofs. 1 Introduction. 2 Finding A Solution Math 38: Graph Theory Spring 2004 Dartmouth College 1 Introduction On Writing Proofs What constitutes a well-written proof? A simple but rather vague answer is that a well-written proof is both clear and

More information

Quadratic Equations Part I

Quadratic Equations Part I Quadratic Equations Part I Before proceeding with this section we should note that the topic of solving quadratic equations will be covered in two sections. This is done for the benefit of those viewing

More information

Accelerated Math. Class work 3. Algebra.

Accelerated Math. Class work 3. Algebra. Accelerated Math. Class work 3. Algebra. We say that a natural number is divisible by another natural number if the result of this operation is a natural number. If this is not the case then we can divide

More information

Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers Solutions

Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers Solutions Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers Solutions Warm-up Problems 1. What is a prime number? Give an example of an even prime number and an odd prime number. A prime number

More information

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Lecture 02 Groups: Subgroups and homomorphism (Refer Slide Time: 00:13) We looked

More information

Q: How can quantum computers break ecryption?

Q: How can quantum computers break ecryption? Q: How can quantum computers break ecryption? Posted on February 21, 2011 by The Physicist Physicist: What follows is the famous Shor algorithm, which can break any RSA encryption key. The problem: RSA,

More information

2. Two binary operations (addition, denoted + and multiplication, denoted

2. Two binary operations (addition, denoted + and multiplication, denoted Chapter 2 The Structure of R The purpose of this chapter is to explain to the reader why the set of real numbers is so special. By the end of this chapter, the reader should understand the difference between

More information