0% found this document useful (0 votes)
36 views14 pages

Week 7 Class 2

This document is the syllabus for a discrete mathematics course titled "Discrete Mathematics I, Math 1056" taught by Dr. Haider at Algoma University. The syllabus outlines that the course will cover topics in number theory and cryptography, including integer representations, algorithms, and binary modular exponentiation. It provides examples and explanations of different number bases such as binary, octal, and hexadecimal, as well as algorithms for converting between bases and computing modular exponents.

Uploaded by

kaushalbasnet988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views14 pages

Week 7 Class 2

This document is the syllabus for a discrete mathematics course titled "Discrete Mathematics I, Math 1056" taught by Dr. Haider at Algoma University. The syllabus outlines that the course will cover topics in number theory and cryptography, including integer representations, algorithms, and binary modular exponentiation. It provides examples and explanations of different number bases such as binary, octal, and hexadecimal, as well as algorithms for converting between bases and computing modular exponents.

Uploaded by

kaushalbasnet988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Discrete Mathematics I

Math 1056

By
Dr. Haider

[email protected]

Department of Computer Science and Mathematics


Algoma University
Number Theory and
Cryptography

Chapter 4

© 2019 McGraw-Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education.
Number Theory and
Cryptography

Chapter 4

• © 2019 McGraw-Hill
© 2019 EducationMcGraw-Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill
Integer Representations and
Algorithms

© 2019 McGraw-Hill Education


Representations of Integers
In the modern world, we use decimal, or base 10,
notation to represent integers. For example when
we write 965, we mean 9∙102 + 6∙101 + 5∙100 .
We can represent numbers using any base b, where
b is a positive integer greater than 1.
The bases b = 2 (binary), b = 8 (octal) , and b = 16
(hexadecimal) are important for computing and
communications
The ancient Mayans used base 20 and the ancient
Babylonians used base 60.
© 2019 McGraw-Hill Education
Base b Representations
We can use positive integer b greater than 1 as a base, because of
this theorem:
Theorem 1: Let b be a positive integer greater than 1. Then if n is a
positive integer, it can be expressed uniquely in the form:
n = akbk + ak-1bk-1 + …. + a1b + a0
where k is a nonnegative integer, a0,a1,…. ak are nonnegative
integers less than b, and ak≠ 0. The aj, j = 0,…,k are called the base-
b digits of the representation.

The representation of n given in Theorem 1 is called the base b


expansion of n and is denoted by (akak-1….a1a0)b.
We usually omit the subscript 10 for base 10 expansions.
© 2019 McGraw-Hill Education
Binary Expansions
Most computers represent integers and do arithmetic with
binary (base 2) expansions of integers. In these expansions,
the only digits used are 0 and 1.
Example: What is the decimal expansion of the integer that
has (1 0101 1111)2 as its binary expansion?
Solution:
(1 0101 1111)2 = 1∙28 + 0∙27 + 1∙26 + 0∙25 + 1∙24 + 1∙23 + 1∙22
+ 1∙21 + 1∙20 =351.
Example: What is the decimal expansion of the integer that
has (11011)2 as its binary expansion?
Solution: (11011)2 = 1 ∙24 + 1∙23 + 0∙22 + 1∙21 + 1∙20 =27.
© 2019 McGraw-Hill Education
Octal Expansions
The octal expansion (base 8) uses the digits
{0,1,2,3,4,5,6,7}.
Example: What is the decimal expansion of the
number with octal expansion (7016)8 ?
Solution: 7∙83 + 0∙82 + 1∙81 + 6∙80 =3598
Example: What is the decimal expansion of the
number with octal expansion (111)8 ?
Solution: 1∙82 + 1∙81 + 1∙80 = 64 + 8 + 1 = 73
© 2019 McGraw-Hill Education
Hexadecimal Expansions
The hexadecimal expansion needs 16 digits, but our decimal
system provides only 10. So letters are used for the
additional symbols. The hexadecimal system uses the digits
{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}. The letters A through F
represent the decimal numbers 10 through 15.
Example: What is the decimal expansion of the number with
hexadecimal expansion (2AE0B)16 ?
Solution:
2∙164 + 10∙163 + 14∙162 + 0∙161 + 11∙160 =175627
Example: What is the decimal expansion of the number with
hexadecimal expansion (E5)16 ?
Solution: 14∙161 + 5∙160 = 224 + 5 = 229
© 2019 McGraw-Hill Education
Base Conversion 1

To construct the base b expansion of an integer n:


• Divide n by b to obtain a quotient and remainder.
n = bq0 + a0 0 ≤ a0 ≤ b
• The remainder, a0 , is the rightmost digit in the base b
expansion of n. Next, divide q0 by b.
q0 = bq1 + a1 0 ≤ a1 ≤ b
• The remainder, a1, is the second digit from the right in the
base b expansion of n.
• Continue by successively dividing the quotients by b,
obtaining the additional base b digits as the remainder.
The process terminates when the quotient is 0.
© 2019 McGraw-Hill Education
Base Conversion 2

Example: Find the octal expansion of (12345)10


Solution: Successively dividing by 8 gives:
• 12345 = 8 ∙ 1543 + 1
• 1543 = 8 ∙ 192 + 7
• 192 = 8 ∙ 24 + 0
• 24 = 8 ∙ 3 + 0
• 3 =8∙0+3
The remainders are the digits from right to left
yielding (30071)8.
© 2019 McGraw-Hill Education
Comparison of Hexadecimal, Octal, and
Binary Representations
TABLE 1 Hexadecimal, Octal, and Binary Representation of the Integers 0 through 15.
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

Octal 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17

Binary 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111

Initial 0s are not shown

Each octal digit corresponds to a block of 3 binary digits.


Each hexadecimal digit corresponds to a block of 4 binary
digits.
So, conversion between binary, octal, and hexadecimal is easy.
© 2019 McGraw-Hill Education
Conversion Between Binary, Octal, and
Hexadecimal Expansions
Example: Find the octal and hexadecimal expansions
of (11 1110 1011 1100)2.
Solution:
• To convert to octal, we group the digits into blocks of
three (011 111 010 111 100)2, adding initial 0s as needed.
The blocks from left to right correspond to the digits
3,7,2,7, and 4. Hence, the solution is (37274) 8.
• To convert to hexadecimal, we group the digits into blocks
of four (0011 1110 1011 1100)2, adding initial 0s as
needed. The blocks from left to right correspond to the
digits 3,E,B, and C. Hence, the solution is (3EBC) 16.
© 2019 McGraw-Hill Education
Binary Modular Exponentiation
In cryptography, it is important to be able to find bn mod m
efficiently, where b, n, and m are large integers.
Use the binary expansion of n, n = (ak-1,…,a1,ao) 2 , to
compute bn .
Note that:
b n  b ak 1  2k 1    a1  2  a0  b ak 1  2 k 1  ba1 .2  b a0
Therefore, to compute bn, we need only compute the values
of b, b2, (b2)2 = b4, (b4)2 = b8, …, and the multiply the terms in
this list, where aj = 1.
Example: Compute 311 using this method.
Solution: Note that 11 = (1011)2 so that 311 = 38 32 31 =
((32)2 )2 32 31 = (92 )2 ∙ 9 ∙3 = (81)2 ∙ 9 ∙3 =6561 ∙ 9 ∙3 =117,147.
© 2019 McGraw-Hill Education

You might also like