Integers and Division Integers and Algorithms - PowerPoint PPT Presentation

Loading...

PPT – Integers and Division Integers and Algorithms PowerPoint presentation | free to view - id: 118586-MjUzZ



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Integers and Division Integers and Algorithms

Description:

Composite: a positive integer that is greater than 1 and is not prime. ... written as the product of primes, where the prime factors are written in order ... – PowerPoint PPT presentation

Number of Views:392
Avg rating:3.0/5.0
Slides: 16
Provided by: isabellebi
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Integers and Division Integers and Algorithms


1
Integers and Division Integers and Algorithms
2
Learning Objectives
  • Integers and division.
  • Integers and algorithms.

3
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

4
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)

5
Integers and Division
  • Theorem if n is a composite integer, then n has
    a prime divisor less than or equal to ?n.
  • demonstration 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.

6
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

7
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

8
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).
  • Example 43 ? 27 (8) (same mod 3).

9
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. 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

10
Integers and Algorithms
  • Euclidean algorithm Euclid 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

11
Integers and Algorithms
  • Algorithm procedure gcd(a,b positive
    integers) x a y b while y gt 0 begin r x
    mod y x y y r end gcd(a,b) is x

12
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

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

14
Integers and Algorithms
  • Algorithm procedure base b expansion(npositive
    integer) q n k 0 while q gt 0 begin ak
    q mod b q ?q/b ? k k 1 end the
    base b expansion of n is (ak…a0)b

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