The Divisibility & Modular Arithmetic: Selected Exercises Goal: Introduce fundamental number theory concepts: The division algorithm Congruences Rules.

Slides:



Advertisements
Similar presentations
CS 202 Epp section ?? Aaron Bloomfield
Advertisements

The Integers and Division. Outline Division: Factors, multiples Exercise 2.3 Primes: The Fundamental Theorem of Arithmetic. The Division Algorithm Greatest.
1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
CSE115/ENGR160 Discrete Mathematics 03/13/12 Ming-Hsuan Yang UC Merced 1.
Number Theory and Cryptography
Congruence class arithmetic. Definitions: a ≡ b mod m iff a mod m = b mod m. a  [b] iff a ≡ b mod m.
CSE115/ENGR160 Discrete Mathematics 03/15/11
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Proof Methods & Strategy
1 Integers and Division CS/APMA 202 Rosen section 2.4 Aaron Bloomfield.
Propositional Equivalence Goal: Show how propositional equivalences are established & introduce the most important such equivalences.
Algorithms: Selected Exercises Goals Introduce the concept & basic properties of an algorithm.
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Pseudo-random Number Generation Qiuliang Tang. Random Numbers in Cryptography ► The keystream in the one-time pad ► The secret key in the DES encryption.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
9/2/2015Discrete Structures1 Let us get into… Number Theory.
CSE 504 Discrete Mathematics & Foundations of Computer Science
Mathematics of Cryptography Part I: Modular Arithmetic
February 24, 2015Applied Discrete Mathematics Week 4: Number Theory 1 Modular Arithmetic Let a be an integer and m be a positive integer. We denote by.
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
CSCE 2100: Computing Foundations 1 Probability Theory Tamara Schneider Summer 2013.
Section 2.1: Shift Ciphers and Modular Arithmetic The purpose of this section is to learn about modular arithmetic, which is one of the fundamental mathematical.
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Copyright © Curt Hill Divisibility and Modular Arithmetic A Topic in Number Theory.
Chapter The Integers and Division Division
Number Theory 이재원 School of Information Technology Sungshin W. University.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
Random Number Generator. Random number Random number: Uniform distribution on [0,1] Random device: dice, coin -> cannot generate the equal sequence.
Elements of Coding and Encryption 1. Encryption In the modern word, it is crucial that the information is transmitted safely. For example, Internet purchases,
Lecture 6.1: Misc. Topics: Number Theory CS 250, Discrete Structures, Fall 2011 Nitesh Saxena.
Chinese Remainder Theorem. How many people What is x? Divided into 4s: remainder 3 x ≡ 3 (mod 4) Divided into 5s: remainder 4 x ≡ 4 (mod 5) Chinese Remainder.
Tuesday’s lecture: Today’s lecture: One-way permutations (OWPs)
Foundations of Computing I CSE 311 Fall Review: Division Theorem Let a be an integer and d a positive integer. Then there are unique integers q.
The man who knew 28% of mathematics. John Von Neumann ( ) Hans Bethe: Academic seminars (10.
9.1 Primes and Related Congruence Equations 23 Sep 2013.
Unit 2 Modular Arithmetic and Cryptography IT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLP 1 Unit 2 Modular Arithmetic and Cryptography.
Discrete Mathematics
CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications.
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
Divisibility and Modular Arithmetic
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
The Fundamentals: Algorithms, Integers, and Matrices CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Module 9.2 Simulations. Computer simulation Having computer program imitate reality, in order to study situations and make decisions Applications?
Chapter 4 With Question/Answer Animations 1. Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
CSE 311 Foundations of Computing I Lecture 12 Modular Arithmetic and Applications Autumn 2012 CSE
CSE 311 Foundations of Computing I Lecture 11 Modular Exponentiation and Primes Autumn 2011 CSE 3111.
Discrete Mathematics Chapter 2 The Fundamentals : Algorithms, the Integers, and Matrices. 大葉大學 資訊工程系 黃鈴玲.
Chapter 3 The Fundamentals: Algorithms, the integers, and matrices Section 3.4: The integers and division Number theory: the part of mathematics involving.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
The Divisibility & Modular Arithmetic: Selected Exercises
B504/I538: Introduction to Cryptography
CSE15 Discrete Mathematics 03/15/17
Propositional Equivalence
Congruence class arithmetic
Integers and Division Section 3.4.
Number Theory and Cryptography
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 3: Algorithms
Applied Discrete Mathematics Week 4: Number Theory
CSE 311 Foundations of Computing I
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Divisibility and Modular Arithmetic
Applied Discrete Mathematics Week 10: Introduction to Counting
Clements MAΘ October 30th, 2014
Presentation transcript:

The Divisibility & Modular Arithmetic: Selected Exercises Goal: Introduce fundamental number theory concepts: The division algorithm Congruences Rules of modular arithmetic

Copyright © Peter Cappello2 Exercise 10 Division Algorithm: Let a  Z, d  Z +.  !q  !r ( 0  r < d  a = dq + r ). What are the quotient & remainder when: a)44 is divided by 8? q: 5, r: 4. b)777 is divided by 21? q: 37, r: 0. c)-123 is divided by 19? q: -7, r: 10. (not q = -6, r = -9) d)-1 is divided by 23? q: -1, r: 22. e)-2002 is divided by 87? q: -24, r: 86. f)0 is divided by 17? q: 0, r: 0. g)1,234,567 is divided by 1001? q: 1233, r: 334. h)-100 is divided by 101? q: -1, r: 1. Remember: remainders are always nonnegative.

Copyright © Peter Cappello3 Exercise 34 Thm. 4. Let m  Z + & a, b  Z. a is congruent to b modulo m, denoted a ≡ b ( mod m ),   k  Z ( a = b + km ). ( m | (a – b) ) Show: if a ≡ b ( mod m ) and c ≡ d ( mod m ), where a, b, c, d, m  Z with m ≥ 2, then a – c ≡ b – d ( mod m ).

Copyright © Peter Cappello4 Exercise 20 Solution Notation: a is congruent to b modulo m is denoted a ≡ b ( mod m ) Thm 4. Let m  Z +. a ≡ b ( mod m )   k  Z, a = b + km. ( m | (a – b) ) Show: if a ≡ b ( mod m ) and c ≡ d (mod m), where a, b, c, d, m  Z with m ≥ 2, then a – c ≡ b – d ( mod m ). Proof (Direct) 1.Assume  k a  Z, a = b + k a m ( Thm 4: a ≡ b (mod m) ) 2.Assume  k c  Z, c = d + k c m ( Thm 4: c ≡ d (mod m) ) 3.a – c = b – d + (k a – k c )m ( 1. – 2. ) 4. a – c ≡ b – d ( mod m ) ( 3. & Thm 4 )

Copyright © Peter Cappello5 Generating Pseudo-random Numbers Generating pseudo-random numbers has important applications. One application area is the Monte Carlo Method. –WikipediaWikipedia –MathWorldMathWorld We glimpse 2 Monte Carlo Method applications crucial to the survival of the human species. –Approximate π –Approximate winning probabilities in Texas Hold’emTexas Hold’em

Copyright © Peter Cappello6 Approximate π Via the Monte Carlo Method (throwing darts) 1 1 1/2 A CIRCLE = π r 2 = π / 4 A SQUARE = 1 A CIRCLE = π / 4 A SQUARE

Copyright © Peter Cappello7 (0, 0 ) ( x, y ) If ( x 2 + y 2 ≤ 1/4 ) then (x, y) is “in” circle. ½ (- ½, - ½ ) (½, ½ )

Copyright © Peter Cappello8 Use the Monte Carlo Method Approximate π : via the Monte Carlo method: double approximatePi( int n ) { int inCircle = 0; for ( int i = 0; i < n; i++ ) { double x = rand( 0, 1 ); double y = rand( 0, 1 ); if ( isInCircle( x – 0.5, y – 0.5 ) ) inCircle++; } return ( 4.0 * inCircle ) / n; // value is a double }

Copyright © Peter Cappello9 boolean inCircle( double x, double y ) boolean isInCircle( double x, double y ) { return x*x + y*y <= 0.25; }

Copyright © Peter Cappello10 Texas Hold 'em “Probability” they given that a player will win hand is approximate. They use the Monte Carlo method: n times: Randomly guess 5 community cards. –For each guess, compute the winner. –Increment his/her winCount: winCount[ winner ]++ Player i approximate probability of winning: winCount[ i ] / n.

Copyright © Peter Cappello11 30: Pseudorandom numbers The linear congruential method uses: 1.a modulus (m), m ≥ 2, 2.a multiplier (a), 2  a < m 3.an increment (c), 0  c < m 4.a seed (x 0 ), 0  x 0 < m It generates the sequence { x n } using the recurrence x n+1 = ( a x n + c ) mod m. Write an algorithm in pseudocode for generating a sequence of pseudorandom numbers using a linear congruential generator.

Copyright © Peter Cappello12 Exercise 30 continued The input is: 1.a modulus 2.a multiplier 3.an increment 4.a seed 5.the number ( n ) of pseudorandom numbers The output is the sequence { x i }.

Copyright © Peter Cappello13 Exercise 30 continued int[] pseudorandom( int modulus, int multiplier, int increment, int seed, int n ) { assert modulus > 1; assert 2 <= multiplier && multiplier < modulus; assert 0 <= increment && increment < modulus; assert 0 <= seed && seed < modulus; int[] x = new int[ n ]; x[0] = seed; for ( int i = 1; i < n; i++ ) x[ i ] = ( multiplier *x[ i – 1 ] + increment ) % modulus; return x; }

End 14