Section 4.5.4

1.  If dk isn’t prime, its prime factors are cast out before dk is tried.

2.  No; the algorithm would fail if pt−1 = pt, giving “1” as a spurious prime factor.

3.  Let P be the product of the first 168 primes. [Note: Although P = 19590 . . . 5910 is a 416-digit number, such a gcd can be computed in much less time than it would take to do 168 divisions, if we just want to test whether or not n is prime.]

4.  In the notation of exercise 3.111,

Σμ,λ2lg max(μ+1,λ)P(μ,λ)=1mΣl1f(l) Πk=1l1(1km),

where f(l) = ∑1≤λl2⌈ lg max(l+1–λ,λ)⌉. If l = 2k+θ, where 0 < θ ≤ 1, we have

f(l)=l2(32θ222θ),

where the function 3 · 2θ – 2 · 2−2θ reaches a maximum of 98 at θ = lg(4/3) and has a minimum of 1 at θ = 0 and 1. Therefore the average ...

Get Art of Computer Programming, Volume 2: Seminumerical Algorithms, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.