25
Natural Numbers 1

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

Embed Size (px)

Citation preview

Page 1: 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

Natural Numbers

1

Page 2: 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

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

Natural Numbers

Page 3: 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

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

Basic Properties for Integers

Page 4: 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

4

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

Page 5: 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

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 = 2351 = 1 . 28 + 0 . 27 + 1 . 26 + 0 . 25 + 1 . 24 + 1 . 23 +

1 . 22 + 1 . 21 + 1 . 20 (351)10 = (101011111)2

5

Representation of Integers

Page 6: 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

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) Determine whether 17 is congruent to 5 modulo 6 and whether 24 and 14 are congruent modulo 6.

2) List five integers that are congruent to 4 modulo 123) Decide whether each of the integers 80, 103, -29, -122 is congruent to 5 modulo 17

6

Modular Arithmetic

Page 7: 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

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 : KA 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

Hashing Function

Page 8: 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

8

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

Page 9: 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

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

Mathematical Induction

Page 10: 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

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

Steps of Induction

Page 11: 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

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

Mathematical Induction

Page 12: 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

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

Page 13: 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

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

Page 14: 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

Example: Use mathematical induction to prove for all positive integers n,

Assumption

True

Group terms to form Sk.

14

2 2 2 2 2 2

1

( 1)(2 1)1 2 3 4 .6

n

i

n n ni n

1( 1)(2( ) 1) 1(2)(2 1) 6 1

611

6 61S

2 2 2 2 2 ( 1)(2 1)1 2 3 46k kS k k k

2 2 21

2 2 21 2 3 4 ( 1)k k kS

2( 1)kS k 2 2 1kS k k

2( 1)(2 1) 2 16

k k k k k Replace Sk by k(k + 1).

Page 15: 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

The formula is valid for all positive integer values of n.

15

( 1)(2 1)6n

n n nS

Example continued:

3 2 22 3 6 12 66 6

k k k k k 3 22 9 13 6

6k k k

2( 3 2)(2 3)6

k k k

( 1)( 2)(2 3)6

k k k

( )[( ) 1][2(1 ) ]6

1 11k k k

Simplify.

Page 16: 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

Prove by Induction (Sums of Powers of Integers) :

16

1

( 1) 1 2 3 412

.n

i

n ni n

2 2 2 2 2 2

1

( 1)(2 1) 1 2 3 42.6

n

i

n n ni n

2 23 3 3 3 3 3

1

( 1) 1 2 3 43.4

n

i

n ni n

24 4 4 4 4 4

1

( 1)(2 1)(3 3 1) 1 2 3 44.30

n

i

n n n n ni n

2 2 25 5 5 5 5 5

1

( 1) (2 2 1) 1 2 3 41

52

.n

i

n n n ni n

Page 17: 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

Second Variants : Suppose that bN 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 nN.

Third Variants (Strong Induction): Suppose that bN 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 nN.

17

Page 18: 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

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)

18

Principle of Strong Mathematical Induction

)1P()P(...)3P()2P()1P( kk

Page 19: 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

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

Page 20: 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

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

Page 21: 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

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

Induction with Nonzero Base Cases

Page 22: 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

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

Page 23: 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

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

Page 24: 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

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

Page 25: 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

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