Natural Numbers

advertisement
1





The set N = {1,2,3,4,……..} is known as natural
numbers or the set of positive integers
The natural numbers are used mainly for :
counting
ordering and
defining other concepts like generating
pseudorandom numbers, assigning memory location
to files, encrypting & decrypting messages, etc.
2
Associative law
(a + b) + c = a + (b + c)
(a * b) * c = a * (b * c)
 Commutative law
a+b=b+c
a*b=b*a
 Distributive Law
a * (b + c) = a * b + a * c
 Additive identity a + 0 = 0 + a = a
 Multiplicative identity a * 1 = 1 * a = a
 Additive inverse
a + (-a) = (-a) + a = 0

3
Prime A +ve integer greater than 1 that has no +ve
divisor 1 and the number itself.
Composite A +ve integer that has atleast one +ve
divisor other than 1 & the number itself
or which is not prime
Fundamental Theorem of Arithmetic
Every +ve integer n > 1 can uniquely be written as
product of prime numbers.
Find the prime factorization of
100, 999, 1024
4
Let b be a +ve integer > 1. Then any +ve integer n
can be uniquely expressed as
n = ak bk + ak-1 bk-1 + ….. + a1 b + a0
where k is a non-negative integer, a0, a1, a2,…, ak
are nonnegative integers  b, and ak ≠ 0
If n = 351, b = 2
351 = 1 . 28 + 0 . 27 + 1 . 26 + 0 . 25 + 1 . 24 + 1 . 23
+ 1 . 22 + 1 . 21 + 1 . 20
(351)10 = (101011111)2
5
If a and b are integers and m is a +ve integer, then a
is congruent to b modulo m
a  b (mod m) if m divides a - b
 a  b (mod m) iff a mod m = b mod m
1)
2)
3)
Determine whether 17 is congruent to 5 modulo 6
and whether 24 and 14 are congruent modulo 6.
List five integers that are congruent to 4 modulo 12
Decide whether each of the integers
80, 103, -29, -122 is congruent to 5 modulo 17
6



For direct access in file handling, the program is
supplied with a key. Using this key, the program
has to locate the required record of information.
Let K be set of keys and A be set of physical
addresses. A function h : KA is called hash
function if h(k) = k mod m where k  K and
m is the number of memory locations.
A hashing function h assigns memory location
h(k) to the record that has k as its key.
7
Example
 If m=111,
 h(037149212) = 037149212 mod 111 = 65
 h(064212848) = 064212848 mod 111 = 14
 h(107405723) = 107405723 mod 111 = 14
This situation creates a collision.
To remove collision, there are two methods:
 Linear Probe
 Chaining
8
is a method of mathematical proof typically
used to establish a given statement for
all natural numbers.
Principle of Mathematical Induction
Let P(n) be a statement about a natural
number n N that is either true or false.
The purpose of induction is to show that
P(n) is true for all n  N.
9

Basis Step
is to prove the given statement for the first
natural number.

Inductive Step
is to prove the given statement for any one
natural number implies the given statement
for the next natural number.
10

Basis Step: P(1) is true

Inductive Step:
Assume that P(k) is true for any k  N
then prove that P(k+1) is true
By principle of mathematical induction,
P(n) is true for all n  N
11
Example:
Use mathematical induction to prove
Sn = 2 + 4 + 6 + 8 + . . . + 2n = n(n + 1)
for every positive integer n.
1.Show that the formula is true when n = 1.
S1 = n(n + 1) = 1(1 + 1) = 2 True
2.Assume the formula is valid for some integer
k. Use this assumption to prove the formula is
valid for the next integer, k + 1 and show that the
formula Sk + 1 = (k + 1)(k + 2) is true.
Sk = 2 + 4 + 6 + 8 + . . . + 2k = k(k + 1) Assumption
12



Example continued:
Sk + 1 = 2 + 4 + 6 + 8 + . . . + 2k + [2(k + 1)]
= 2 + 4 + 6 + 8 + . . . + 2k + (2k + 2)
= Sk + (2k + 2)
Group terms to form Sk.
= k(k + 1) + (2k + 2)
Replace Sk by k(k + 1).
= k2 + k + 2k + 2
Simplify.
= k2 + 3k + 2
= (k + 1)(k + 2)
= (k + 1)((k + 1)+1)
The formula Sn = n(n + 1) is valid for all positive
integer values of n.
13
n
i
2
1  2 3  4 
2
2
2
2
i 1
S1 
n(n  1)(2n  1)
n 
.
6
2
11
(  1)(2(1)  1) 1(2)(2  1) 6

 1
6
6
6
Sk  1  2  3  4 
2
2
2
2
Sk 1  12  22  32  42 
True
k (k  1)(2k  1)
k 
6
2
Assumption
 k 2  (k  1)2
 Sk  (k  1) 2
 S k  k 2  2k  1

Group terms to form Sk.
k (k  1)(2k  1)
 k 2  2k  1 Replace Sk by k(k + 1).
6
14
Example continued:
3
2
2
2
k

3
k

k
6
k
 12k  6


6
6
3
2
2
k

9
k
 13k  6

6
(k 2  3k  2)(2k  3)

6
(k  1)(k  2)(2k  3)

6
(k  1)[(k  1)  1][2(k  1)  1]

6

Simplify.
n  1)
The formula Sn  n(n  1)(2
is valid for all
6
positive integer values of n.
15
Prove by Induction (Sums of Powers of Integers) :
n(n  1)
n
2
n
1.
 i  1 2  3  4 
i 1
n
2.
2
2
2
2
2
i

1

2

3

4


 n2 
i 1
n
3.
3
3
3
3
3
i

1

2

3

4


i 1
i
1  2 3  4 
n(n  1)(2n  1)(3n 2  3n  1)
n 
30
5
1  2 3  4 
n 2(n  1) 2(2n 2  2n  1)
n 
12
4
4
4
4
i 1
n
5.
i
i 1
2
2
n
(
n

1)
 n3 
4
4
n
4.
n(n  1)(2n  1)
6
5
5
5
5
4
5
16

Second Variants : Suppose that bN and that
we can prove these two statements:
Base Case: P(k) is true for 0≤k≤b.
Inductive Step: If P(k) is true for some k≥b, then
P(k+1) is also true.
Then, P(n) is true for all nN.

Third Variants (Strong Induction): Suppose
that bN and we can prove two statements:
Base Case: P(k) is true for 0≤k≤b.
Inductive Step: If k≥b and P(i) is true for all i≤k,
then P(k+1) is also true.
Then, P(n) is true for all nN.
17
Let P(n) be statement involving positive
integer n=1,2,3,… then
 Step 1: Verify P(1) is true. (Basis Step)
 Step 2: Assume that P(1),P(2),…,P(k) is true
(Strong Inductive Hypothesis)
 Step 3: Verify that P(k+1) is true using strong
inductive hypothesis. (Inductive Step)

P(1)  P(2)  P(3)  ...  P(k )  P(k 1)
18





A chocolate bar consists of a number of
squares (say, n>0) arranged in a rectangular
pattern. You split the bar into small squares
always breaking along the lines between the
squares. Prove that minimum number of
breaks it takes is n-1.
Let P(n) denote the number of breaks needed
to split a bar with n squares.
Base Step: P(1)=0 is true.
Inductive Step: Assume that P(k) is true for
2≤k≤n.
To prove that P(k+1)=k under the above
assumption.
19




Break the bar into two pieces of sizes n1 and
n2, so that n1+n2=k+1.
By inductive hypothesis
P(n1) = n1-1
P(n2) = n2-1
Hence the total number of breaks is
1+(n1-1)+(n2-1) = k
Hence P(n) holds for all n>0.
20

Sometimes we want to prove that some property P
holds for all integers n ≥ b.

Inductive Argument:
P(b) : Show that property P is true for b
P(k) ⇨ P(k+1) : Show that if property P is true for k,
then it’s true for k+1.

We can conclude that P(n) holds for all n ≥ b.
We don’t care about n < b.

21





Example: Prove using strong induction that
every amount of postage of 8 cents or more can
be formed using just 3-cent and 5-cent
stamps.
Let P(n) be the proposition that postage of n>8
cents can be formed using 3-cent and 5-cent
stamps.
BASIS STEP: 8=3+5
P(8) uses one 3-cent and one 5-cent stamp.
P(8) is true.
22





INDUCTIVE STEP: Suppose it’s true for k.
There are two cases:
(1) If used a 5-cent stamp to make k, replace
it by two 3-cent stamps. Get k+1.
(2) If did not use a 5-cent stamp to make k,
must have used at least three 3-cent stamps.
Replace three 3-cent stamps by two 5-cent
stamps. Get k+1.
Hence, P(n) holds for all n ≥ 8.
23






Example: Use strong mathematical induction to
show that if n is an integer > 1, then n can be
written as the product of primes.
Let P(n) be the proposition that n can be
written as a product of primes.
BASIS STEP: P(2) is true since 2 itself is prime.
INDUCTIVE STEP: The inductive hypothesis P(j)
is true for all integers j with 2 ≤ j ≤ k.
To show that P(k + 1) must be true under this
assumption, two cases arise Case–1: If k + 1 is prime, then P(k + 1) is true.
24
Case-2: If k + 1 is composite

k+1 = a.b
where a & b are +ve integers with 2≤a≤ b<k+1
By the inductive hypothesis,
a & b can be written as the product of primes
k + 1 can also be written as the product of
those primes.


Hence, by strong mathematical induction,
every integer > 1 can be written as the
product of primes.
25
Download