Integers and Division Integers and Algorithms - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Integers and Division Integers and Algorithms

Description:

Prime numbers and some of their properties. The division algorithm. ... great prime numbers, stopping at 97=9. 2,3,5,7 do not divide 97, so it is prime. ... – PowerPoint PPT presentation

Number of Views:212
Avg rating:3.0/5.0
Slides: 18
Provided by: isabellebi
Category:

less

Transcript and Presenter's Notes

Title: Integers and Division Integers and Algorithms


1
Integers and DivisionIntegers and Algorithms
2
Learning Objectives
  • Definition of integer division.
  • Properties of division.
  • Prime numbers and some of their properties.
  • The division algorithm.
  • Greatest Common Divisor and Least Common
    Multiple.
  • Congruences, modular arithmetic.

3
Learning Objectives
  • Integers and algorithms
  • the Euclidian algorithm
  • the extended Euclidian algorithm
  • Further results in number theory.
  • Some applications of number theory
  • computer arithmetic with large numbers
  • public key cryptography

4
Integers and Division
  • Division if a and b are integers with a ? 0, we
    say that a divides b if there is an integer c
    such that b ac.
  • Factor when a divides b, we say that a is a
    factor of b.
  • Multiple when a divides b, we say that b is a
    multiple of a.
  • Notation a b (a divides b).
  • Example 3 27 but not 2 17

5
Integers and Division
  • Prime a positive integer p greater than 1 is
    called prime if the only positive factors of p
    are 1 and p.
  • Composite a positive integer that is greater
    than 1 and is not prime.
  • List of primes 2,3,5,7,11,13,17,19,23,29,31,37,41
    ,43,47,53
  • The fundamental theorem of arithmetic every
    positive integer can be written as the product of
    primes, where the prime factors are written in
    order of increasing size.
  • Examples of prime factorizations (Maple
    ifactor(n)) gt ifactor(31722722304)

6
Integers and Division
  • Theorem if n is a composite integer, then n has
    a prime divisor less than or equal to ?n.
  • proof there exist a and b, n a.b. We need to
    have a ? ?n or b ? ?n because otherwise a.b
    would be greater than n. Let us suppose that a ?
    ?n. If a is prime, QED. If it is a composite,
    then a still has a prime divisor smaller than ?n,
    QED.
  • Example find the prime factorization of 97.
  • Try to divide 97 by increasingly great prime
    numbers, stopping at ? 979. 2,3,5,7 do not
    divide 97, so it is prime.

7
Integers and Division
  • Division algorithm let a be an integer and d a
    positive integer. Then there are unique integers
    q and r, with 0 ? r lt d, such that a dq r.
  • Divisor d.
  • Dividend a.
  • Quotient q.
  • Remainder r. Also called modulus.
  • Examples irem(145,34) 9
  • iquo(145,34) 4

8
Integers and Division
  • Greatest Common Divisor let a and b be two
    integers, not both zero. The largest integer d
    such that d a and d b is called the greatest
    common divisor of a and b, and is noted gcd(a,b).
    (take all common - divisors with smallest
    exponent).
  • Least Common Multiple the least common multiple
    of the positive integers a and b is the smallest
    positive integer that is divisible by both a and
    b, and it is noted lcm(a,b). (take all divisors
    with largest exponent).
  • Examples
  • igcd(129, 39) 3
  • ilcm(129,39) 1677

9
Integers and Division
  • Properties
  • ab gcd(a,b) . lcm(a,b)
  • Modular arithmetic
  • two integers a and b are congruent modulo m (m
    integer gt 0) if m divides a-b. It is denoted as
    a ? b (mod m).
  • We can also say that they have the same remainder
    when divided by m.
  • Example 43 ? 27 (8) (same modulus 3).

10
Integers and Division
  • Properties of congruences
  • If a ? b (mod m) and c ? d (mod m), thena c
    ? b d (mod m)
  • Proof If a ? b (mod m), then there is a k such
    as a b km. There is also an l such as c b
    lm.By additive property of equality, we have
    ac bd(kl)m, and a c ? b d (mod m).
    QED

11
Integers and Division
  • Applications
  • Hashing functions permits to allocate a memory
    space to a piece of data. For example, if storage
    available is a table of size 20, a number n to
    store will be associated the cell n mod 20.
    Problem potential collisions.
  • Cryptology science of secret messages.Julius
    Caesar encryption code shift each letter 3
    positions forward in the alphabet (a --gt d, z--gt
    c, ).f(p) (p3) mod 26, where p is a code for
    each letter between 0 and 25 (A ? 0, , Z?
    25).AN EXAMPLE --gt 0 13 4 23 0 12 15 11
    4--gt 3 16 7 0 3 15 18 14 7 --gt DQ HADPSOH

12
Integers and Algorithms
  • Euclidean algorithmEuclid proposed this
    algorithm to calculate the gcd of two
    numbers.Let abqr, where a,b,q,r are integers.
    Then gcd(a,b)gcd(b,r).If d divides a and b, it
    divides also r because ra-bq. So all common
    divisor of a and b is also a common divisor of b
    and r.If d divides b and r, it divides also a
    because abqr. So all common divisors of b and r
    are also common divisors of a and b.
  • Examplegcd(662,414) gcd(414,248)
    gcd(248,166) gcd(166,82) gcd(82,2) 2

13
Integers and Algorithms
  • Algorithm procedure gcd(a,b positive
    integers)x ay bwhile y gt 0begin r x
    mod y x y y rend gcd(a,b) is x

14
Integers and Algorithms
  • Base b expansion representation of n such that
  • where n is a positive integer, k is
    a nonnegative integer, a0, a1, , ak
    are nonnegative integers lt b
  • ak ? 0
  • Example binary expansion, where all digits are
    either 0 or 1. Hexadecimal expansion, where all
    digits are 0,1, , 9, A, B, C, D, E, F

15
Integers and Algorithms
  • Examples
  • (101011)2 25 23 21 20 43
  • 145 (10010001) 2
  • (3A5)16 3.162 10.161 5
  • 145 (91)16

16
Integers and Algorithms
  • Algorithmprocedure base b expansion(npositive
    integer)q nk 0while q gt 0begin ak
    q mod b q ?q/b ? k k 1end the
    base b expansion of n is (aka0)b

17
Integers and Algorithms
  • Integer operations algorithms to perform
    operations directly on binary expansions.
  • Example addition O(n)
  • procedure add(a,bpositive integers)c 0for
    j 0 to n-1begin d ?(aj bj c)/2 ?
    sj aj bj c - 2d d is the next
    carry c dendsn c the binary
    expansion of the sum is (snsn-1 s1s0)2
Write a Comment
User Comments (0)
About PowerShow.com