Electronic Devices and Circuit Theory - 11th Edition
Electronic Devices and Circuit Theory - 11th Edition
Note: If a | b, then
a is called a factor of b
b is called a multiple of a
Examples:
Does 4 | 16?
Does 3 | 11?
Does 7 | 42?
Examples:
Does 4 | 16? Yes, 16 = 4 × 4
Does 3 | 11? No, because 11/3 is not an
integer
Does 7 | 42? Yes, 42 = 7 × 6
Terminology: Given a = dq + r
d is called the divisor
q is called the quotient
r is called the remainder
q = a div d
r = a mod d
Examples
Question: What are the quotient and remainder when 123 is
divided by 23?
System.out.println(y/x);
System.out.println(y%x); Prints out 2.5
System.out.println(y/z);
}
This can be a source of many errors, so be careful in
your future classes!
Group work!
Problem 1: Does
1. 12 | 144
2. 4 | 67
3. 9 | 81
Examples:
Is 17 congruent to 5 modulo 6?
Is 24 congruent to 14 modulo 6?
Since remainders can be so important, they have
their own special notation!
Definition: If a and b are integers and m is a positive
integer, we say that a is congruent to b modulo m if
m | (a – b). We write this as a ≡ b mod m.
Examples:
Is 17 congruent to 5 modulo 6? Yes, since 6 | (17 – 5)
Is 24 congruent to 14 modulo 6? No, since 6 | (24 – 14)
Properties of congruencies
1. Hash functions
2. The generation of pseudorandom numbers
3. Cryptography
Hash functions allow us to quickly and
efficiently locate data
Problem: Given a large collection of records, how can we find the
one we want quickly?
0 1 2 3 4 5 6 7
Memory:
42 mod 8 = 2 10 mod 8 = 2
ID: 42 ID: 10
… …
… …
42 mod 3 = 0 9 mod 3 = 0
ID: 42 ID: 9
… …
… …
Many areas of computer science rely on the ability to
generate pseudorandom numbers
Coding algorithms
Network protocols
Congruencies can be used to generate
pseudorandom sequences
Example: m = 9, a = 7, c = 4, x0 = 3
x1 = 7x0 + 4 mod 9 = 7 × 3 + 4 mod 9 = 25 mod 9 = 7
x2 = 7x1 + 4 mod 9 = 7 × 7 + 4 mod 9 = 53 mod 9 = 8
x3 = 7x2 + 4 mod 9 = 7 × 8 + 4 mod 9 = 60 mod 9 = 6
x4 = 7x3 + 4 mod 9 = 7 × 6 + 4 mod 9 = 46 mod 9 = 1
x5 = 7x4 + 4 mod 9 = 7 × 1 + 4 mod 9 = 11 mod 9 = 2
…
The field of cryptography makes heavy use of
number theory and congruencies
Cryptography is the study of secret messages
Uses of cryptography:
Protecting medical records
Storing and transmitting military secrets
Secure web browsing
…
Problem 1:
1. Is 4 congruent to 8 mod 3?
2. Is 45 congruent to 12 mod 9?
3. Is 21 congruent to 28 mod 7?
Next time:
Prime numbers, GCDs, integer representation (Section 3.5)