Lecture 7 Number Theory Euiseong Seo

Similar documents
Lecture 7: Number Theory Steven Skiena. skiena

Solution Sheet (i) q = 5, r = 15 (ii) q = 58, r = 15 (iii) q = 3, r = 7 (iv) q = 6, r = (i) gcd (97, 157) = 1 = ,

The Euclidean Algorithm and Multiplicative Inverses

Outline. Number Theory and Modular Arithmetic. p-1. Definition: Modular equivalence a b [mod n] (a mod n) = (b mod n) n (a-b)

8 Primes and Modular Arithmetic

a the relation arb is defined if and only if = 2 k, k

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?

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

Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems

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

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. Congruences. Congruence: definitions and properties

3 The fundamentals: Algorithms, the integers, and matrices

Number Theory Notes Spring 2011

Numbers. Çetin Kaya Koç Winter / 18

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

Applied Cryptography and Computer Security CSE 664 Spring 2017

Introduction to Information Security

Discrete Structures Lecture Primes and Greatest Common Divisor

4 Number Theory and Cryptography

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

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

MTH 346: The Chinese Remainder Theorem

Chapter 4 Finite Fields

Number Theory and Group Theoryfor Public-Key Cryptography

Addition. Ch1 - Algorithms with numbers. Multiplication. al-khwārizmī. al-khwārizmī. Division 53+35=88. Cost? (n number of bits) 13x11=143. Cost?

CMPUT 403: Number Theory

Ch 4.2 Divisibility Properties

Topics in Cryptography. Lecture 5: Basic Number Theory

ax b mod m. has a solution if and only if d b. In this case, there is one solution, call it x 0, to the equation and there are d solutions x m d

Number Theory. Zachary Friggstad. Programming Club Meeting

Lecture Notes. Advanced Discrete Structures COT S

CISC-102 Winter 2016 Lecture 11 Greatest Common Divisor

1 Overview and revision

Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m

Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

COMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635

Number Theory. Modular Arithmetic

CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

Lecture 11 - Basic Number Theory.

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

Elementary Number Theory MARUCO. Summer, 2018

CPSC 467b: Cryptography and Computer Security

Number Theory & Modern Cryptography

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald)

Introduction to Cryptography. Lecture 6

7. Prime Numbers Part VI of PJE

basics of security/cryptography

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

Chapter 2. Divisibility. 2.1 Common Divisors

18 Divisibility. and 0 r < d. Lemma Let n,d Z with d 0. If n = qd+r = q d+r with 0 r,r < d, then q = q and r = r.

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

CSE 20 DISCRETE MATH. Winter

3.2 Solving linear congruences. v3

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

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 3

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

Number Theory Alex X. Liu & Haipeng Dai

Primes and Modular Arithmetic! CSCI 2824, Fall 2014!!

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

Introduction to Number Theory 1. c Eli Biham - December 13, Introduction to Number Theory 1

Maths Probability Problems. Maths. League of Programmers. ACA, IIT Kanpur. October 22, 2012

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

Math From Scratch Lesson 20: The Chinese Remainder Theorem

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

4. Congruence Classes

Number Theory Proof Portfolio

Chapter 9 Basic Number Theory for Public Key Cryptography. WANG YANG

Elementary Number Theory. Franz Luef

1. (16 points) Circle T if the corresponding statement is True or F if it is False.

Basic elements of number theory

4 Powers of an Element; Cyclic Groups

Basic elements of number theory

ALG 4.0 Number Theory Algorithms:

Introduction to Number Theory

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

CSE20: Discrete Mathematics

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

The Chinese Remainder Theorem

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.

Q 2.0.2: If it s 5:30pm now, what time will it be in 4753 hours? Q 2.0.3: Today is Wednesday. What day of the week will it be in one year from today?

CSC 474 Information Systems Security

Discrete Mathematics GCD, LCM, RSA Algorithm

ECEN 5022 Cryptography

MATH 4400 SOLUTIONS TO SOME EXERCISES. 1. Chapter 1

Number Theory Basics Z = {..., 2, 1, 0, 1, 2,...} For, b Z, we say that divides b if z = b for some. Notation: b Fact: for all, b, c Z:

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

Clock Arithmetic. 1. If it is 9 o clock and you get out of school in 4 hours, when do you get out of school?

2 Elementary number theory

MATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology.

For your quiz in recitation this week, refer to these exercise generators:

Chapter 3 Basic Number Theory

ECE596C: Handout #11

Modular Arithmetic Instructor: Marizza Bailey Name:

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

[Part 2] Asymmetric-Key Encipherment. Chapter 9. Mathematics of Cryptography. Objectives. Contents. Objectives

This exam contains 5 pages (including this cover page) and 4 questions. The total number of points is 100. Grade Table

Discrete Structures Lecture Solving Congruences. mathematician of the eighteenth century). Also, the equation gggggg(aa, bb) =

M381 Number Theory 2004 Page 1

Transcription:

Lecture 7 Number Theory Euiseong Seo (euiseong@skku.edu) 1

Number Theory God created the integers. All else is the work of man Leopold Kronecker Study of the property of the integers Specifically, integer divisibility Full of beautiful proofs and surprising results b divides a b a a = bk for some integer k b is a divisor of a a is a multiple of b 2

Prime Numbers Prime Numbers integers p > 1 which are only divisible by 1 and itself if p is a prime numner, then p = a*b for integers a <= b implies that a = 1 and b = p Fundamental theorem of arithmetic Every integer can be expressed in only one way as the product of primes Examples 105 = 3 * 5 * 7 32 = 2 * 2 * 2 * 2 * 2 Prime factorization Any number which is not prime is a composite 3

Primality Testing and Factorization There are an infinite number of primes (Euclid s proof) x / ln x number of primes that are less than or equal to x The smallest prime factor of n is at most n unless n is a prime 4

Constructing All Divisors Every divisor is the product of some subset of these prime factors Such subsets can be constructed using backtracking techniques Be careful about duplicate prime factors 12 has three terms but has only six divisors 5

Greatest Common Divisor Largest divisor shared by a given pair of integers Used to obtain the reduced form of a fraction Euclid s GCD algorithms If b a, then gdb(a,b) = b If a = bt + r for integers t and r, then gcd(a,b) = gcd(b,r) ax + by = gcd(a,b) 6

Greatest Common Divisor /* Find the gcd(p,q) and x,y such that p*x + q*y = gcd(p,q) */ long gcd(long p, long q, long *x, long *y) { long x1,y1; /* previous coefficients */ long g; /* value of gcd(p,q) */ if (q > p) return(gcd(q,p,y,x)); if (q == 0) { *x = 1; *y = 0; return(p); } g = gcd(q, p%q, &x1, &y1); *x = y1; *y = (x1 - floor(p/q)*y1); } return(g); 7

Least Common Multiple The smallest integer which is divided by both of a given pair of integers lcm(x,y) = xy / gcd(x,y) 8

Modular Arithmetic What day of the week will your birthday fall on next year? Modular arithmetic modulus residue (x+y) mod n = ((x mod n) + (y mod n)) mod n (12 mod 100) (53 mod 100) = -41 mod 100 = 59 mod 100 xy mod n = (x mod n)(y mod n) mod n x y mod n = (x mod n) y mod n 9

Modular Arithmetic Finding the last digit What is the last digit of 2 100? 10

Congruences An alternate notation for representing modular arithmetic a b (mod n) if m (a-b) By definition, if a mod m is b, then a b (mod n) What integers x satisfy the congruence x 3 (mod 9)? What about 2x 3 (mod 9) and 2x 3 (mod 4)? 11

Operations on Congruences Congruences support addition, subtraction, and multiplication, as well as a limited form of division Addition and subtraction a b (mod n) and c d (mod n) -> a+c b+d (mod n) Multiplication a b (mod n) and c d (mod n) -> ac bd (mod n) Division 6 * 2 6 * 1 (mod 3) -/-> 2 1 (mod 3) ad bd (mod dn) -> a b (mod n) 12

Solving Linear Congruences A linear congruence An equation of the form ax b (mod n) Solving means identifying which values of x satisfy it Not all linear congruences have solutions ax 1 (mod n) has a solution if and only if the modulus and the multiplier are relatively prime Using Euclid s algorithm to find this inverse ax 1 (mod n) -> ax ax + ny (mod n) Since ny 0 (mod n), this inverse is the x from Euclid s algorithm 13

Solving Linear Congruences In general, there are three cases depending on the relationship between a, b, and n gcd(a,b,n) > 1 We can divide all three terms by this divisor to get an equivalent congruence This gives us a single solution mod the new base, or equivalently gcd(a,b,n) solutions (mod n) gcd(a,n) does not divide b The congruence can have no solution gcd(a,b) = 1 There is one solution (mod n) x = a -1 b works since aa-1b b (mod n) Inverse exists and can be found using Euclid s algorithm 14

More Advanced Tools Chinese remainder theorem Gives us a tool for working with systems of congruence over different moduli Suppose there exists an integer x such that x a 1 (mod m 1 ) and x a 2 (mod m 2 ), then x is uniquely determined (mod m 1 m 2 ) if m 1 and m 2 are relatively prime 15

Diophantine Equations Formulae in which the variables are restricted to integers Fermat s last theorem a n + b n = c n Linear Diophatine equation ax ny = b, where x and y are the integer variables and a, b, and n are integer constants Equivalent to ax b (mod n) 16

Light, More Light There is man named Mabu who switches on-off the lights along a corridor at our university. Every bulb has its own toggle switch that changes the state of the light. If the light is off, pressing the switch turns it on. Pressing it again will turn it off. Initially each bulb is off. He does a peculiar thing. If there are n bulbs in a corridor, he walks along the corridor back and forth n times. On the ith walk, he toggles only the switches whose position is divisible by i. He does not press any switch when coming back to his initial position. The ith walk is defined as going down the corridor (doing his peculiar thing) and coming back again. Determine the final state of the last bulb. Is it on or off? Input The input will be an integer indicating the nth bulb in a corridor, which is less than or equal to 2 32 1. A zero indicates the end of input and should not be processed. Output Output yes or no to indicate if the light is on, with each case appearing on its own line. 17

Light, More Light Sample Input 3 6241 8191 0 Sample Output no yes no 18

Factovisors The factorial function, n! is defined as follows for all non-negative integers n: 0! = 1 n! = n (n 1)! (n >0) We say that a divides b if there exists an integer k such that k a = b Input The input to your program consists of several lines, each containing two non-negative integers, n and m, both less than 2 31. Output For each input line, output a line stating whether or not m divides n!, in the format shown below. 19

Factovisors Sample Input 6 9 6 27 20 10000 20 100000 1000 1009 Sample Output 9 divides 6! 27 does not divide 6! 10000 divides 20! 100000 does not divide 20! 1009 does not divide 1000! 20