<<

ELEMENTARY RESULTS ON THE FIBONACCI NUMBERS

ROGÉRIO THEODORO DE BRITO

Contents 1. Introduction 1 2. Denition and Elementary Properties 1 3. Other Properties of the Golden 6 4. Algorithms for the Fibonacci Numbers 7 5. “Appearances” of the Fibonacci Numbers 7 6. The Fibonacci numbers and their siblings 9 7. Fibonacci Numbers and Linear Algebra 9 8. Fibonacci Numbers and Their use in Analysis of Algorithms 9 References 12

1. Introduction The Fibonacci Numbers arise in plenty of situations of our days (even if in disguise) and they fascinate a lot of people for the abundance of their properties. It is remarkable that such a sequence presents so many connections with a number of branches of , ranging from Complex Variables to Abstract Algebra, from Discrete Mathematics [4] to Linear Algebra, from Elementary Number Theory [1] to Analysis of Algorithms [2], just to cite a few. It is the purpose of these short notes to present (in a very easy way—perhaps, accessible even to high-school students) some of the most widely known and elementary facts regarding such intriguing numbers. The reader can nd many other sources of material for further study (including a journal entirely devoted to Fibonacci Numbers, the Fibonacci Quarterly Journal!) in the references. They contain a number of much deeper results that are outside the scope of these modest notes.

2. Definition and Elementary Properties The Fibonacci Numbers can be dened in many dierent (and equivalent) ways, but the most common denition seemsDRAFT to be the fact that they are a sequence of that can be dened by a very simple recurrence relation:   0, if i = 0  Fi = 1, if i = 1   Fi −1 + Fi −2, if i ≥ 2 Notice that starting with the third number of the sequence, a given can be calculated as the sum of its two predecessors in the sequence. This means that the rst numbers can be listed as illustrated by the following table: i 0 1 2 3 4 5 6 7 8 9 10 11 12 13 . Fi 0 1 1 2 3 5 8 13 21 34 55 89 144 233

Date: January 27, 2013. 1 2 ROGÉRIO THEODORO DE BRITO

This is a good moment to remark that some authors dene the Fibonacci numbers starting with index 1, instead of what we did here. As the reader will shortly see, the way we dened these numbers has advantages that will be obvious soon, while, at the same time, describing the sequence in a slightly more general way (we will also see further generalizations soon).

2.1. Some Basic Properties of the Fibonacci Numbers. A little observation of the rst few numbers listed in the table above suggests that the sequence might satisfy some relations. For instance, summing the rst four terms of the sequence gives 0 + 1 + 1 + 2 = 4 = 5 − 1; summing the rst ve terms gives us 0 + 1 + 1 + 2 + 3 = 7 = 8 − 1. This seems to suggest us that summing the rst n terms of the sequence results in the (n + 2)-th term minus one, and this is indeed the case, as we will prove in the following proposition. Proposition 1. For each natural n ≥ 1, we have

(1) F0 + F1 + ··· + Fn−1 = Fn+1 − 1. Proof. Since the sequence is dened by a recurrence relation, the most straightforward way of proving it is by induction on n. If n = 1, then the left side of the equation would consist of F0 = 0 = 1 − 1 = F1 − 1, and the fact holds for n = 1. If n = 2, then we would have F0 + F1 = 0 + 1 = 1 = 2 − 1 = F3 − 1 and it is also OK for this case. The reader is encouraged to verify the assertion for other values of n, to gain a little more condence on what we are trying to prove. Let us assume then that our hypothesis is valid for all integers n such that 1 ≤ n < n0 0 0 −1 Pn 0 and let’s prove that it is also true for n . By our induction hypothesis, k=0 Fk = Fn +1 − 1. Summing Fn0 to both sides of this equation gives 0 Xn Fk = Fn0 + Fn0+1 − 1 = Fn0+2 − 1, k=0 where the last equation is simply a use of the denition of the Fibonacci numbers and this concludes our proof. 

Other facts can be easily inferred from the table of our rst numbers: Proposition 2. For any natural n ≥ 0, we have:

(2) F1 + F3 + F5 + ··· + F2n+1 = F2n+2

(3) F0 + F2 + F4 + F6 + ··· + F2n = F2n+1 − 1 Proof. Like the previous proposition, both facts here can be proved by induction on n. We now proceed to ...  In fact, “merging” the formulasDRAFT stated in Proposition 2, we can derive Proposition 1 as a corollary, obtaining, thus, a second proof for the sum of the rst Fibonacci numbers.

Alternate proof of Proposition 1. Since we already know that F1+···+F2n+1 = F2n+2 and that P2n+1 F0+F2+···+F2n = F2n+1−1, summing both equation, we get k=0 Fk = (F2n+1−1)+F2n+2 = F2n+3 −1. Changing the variables conveniently, we get the result stated in the corollary.  2.2. The and Some Elementary Facts. Before talking more about the Fibonacci numbers, we take some moments for a little digression regarding some other numbers that are quite important and, as we shall see, they present strong (and, sometimes, remarkably surprising) connections with the Fibonacci numbers. √ 1 5 Denition 1 (The Golden Ratio and Its Conjugate). The real number ϕ = + is called √ 2 ˆ 1− 5 the golden ratio and the number ϕ = 2 is called the golden ratio conjugate. ELEMENTARY RESULTS ON THE FIBONACCI NUMBERS 3

Both numbers that we have just dened occur frequently enough (including in others areas like Geometry and Architecture, for instance) that they have received attention of many authors and, as a consequence, dierent terminology is in use regarding such numbers. For instance, ϕ is also called the “divine proportion” (among other names) and the number ϕˆ is, sometimes, called the “silver ratio”. One rst elementary result involving ϕ and ϕˆ is that they are the roots of the polynomial p(x) = 1 + x − x 2 (and this can be easily seen by the quadratic formula). This means, in particular, that they satisfy x 2 = x + 1 and, in other words, we have the following fact: Proposition 3. Both the golden ratio ϕ and its conjugate ϕˆ satisfy the equality x 2 = x + 1. 2 √ 2 √ √ Proof. We have ϕ = (1 + 5)√ /4 = (1 + 2 5 √+ 5)/4 = (6 + 2 5)/4. Simplifying this latter equation, we have ϕ2 = (3 + 5)/2 = 1 + (1 + 5)/2 = 1 + ϕ2. The same can be veried for the conjugate of the golden ratio, which we leave as an exercise.  In other words, if we wish to calculate ϕ squared, we can do that simply by adding 1 to ϕ. The same is true for ϕˆ. In fact, ϕ has some other interesting properties: Proposition 4. If ϕ is the golden ratio, then ϕ − 1 = −ϕˆ. √ √ √ Proof. This is a quite direct fact, since ϕ −1 = (1+ 5)/2−1 = (−1+ 5)/2 = −(1− 5)/2 = −ϕˆ.  Proposition 5. If ϕ is the golden ratio, then 1/ϕ = −ϕˆ. √ 2 1 5 √ √ Proof. Since 1/ϕ = √ · −√ , we have 1/ϕ = 2(1 − 5)/ − 4 = −(1 − 5)/2 = −ϕˆ.  1+ 5 1− 5 From the Proposition 5, we can formally state the same fact in equivalent, but convenient ways for our future uses: Corollary 6. For the golden ratio ϕ, we have ϕϕˆ = −1. Equivalently, we have 1/ϕˆ = −ϕ. Proof. Both facts are simply re-statements of the result of the earlier proposition.  And we can, actually, say a little more about the golden ratio, as the following proposi- tion asserts: √ Proposition 7. For the golden ratio ϕ and its conjugate ϕˆ, we have ϕ −ϕˆ = 5 and ϕ +ϕˆ = 1. Proof. Again, both facts admit quite straight verications.  2.3. Generating Functions and the Fibonacci Numbers. It is a fortunate case that many sequences may be “compactly” represented by a single, “simple” univariate function, whose Taylor-Maclaurin expansion (around 0)[5] has the i-th sequence number as the coecient of the i-th power of the variable x. Functions that have such properties are called generating functions [8]. It should be made explicit hereDRAFT that these functions are formal series and we are not par- ticularly concerned about convergence. If the function actually happens to be convergent for some values of x, then we can possibly use this fact for deriving other properties, but our main purpose is to just nd a function that has the chosen numbers as the coecients of the powers of the variable.1 For instance, we can easily nd a generating function the sequence h1, 1,..., 1,...i, that is, the sequence composed of ones only: its generating function is f (x) = 1 + x + x 2 + ··· + x i + ··· = 1/(1 − x). The reader not used to generating functions may be wondering what is, the, so special about generating functions that makes it deserve our attention. In fact a slight modication of the generating function f (x) can give us some

1In other words, we are mainly interested in the ring C[[X]] of formal series with complex numbers as the coecients. 4 ROGÉRIO THEODORO DE BRITO not so trivial results, as we shall see. Indeed, the sequence h1, 3, 9, 27, 81,...i of powers of 3 is simply g(x) = f (3x) = 1/(1 − 3x) and, in general, the generating function for the geometric sequence h1, q, q2, q3,...i of powers of a real number q is easily seen to be fq (x) = 1/(1 − qx). Quite a good deal more sequences may be described by a suitably “simple” generating function. Just as one simple example, we can see that h0, 1, 2, 3, 4, 5,...i, comprised of the natural numbers is the formal derivative of f (x), that is 0 + 1 + 2x + 3x 2 + ··· +ix i −1 + ··· = [1/(1 − x)]0 = 1/(1 − x)2, which is a simple way of describing the natural numbers in a very compact fashion.

2.3.1. Is There a Generating Function for the Fibonacci Numbers? But would there be a such a compact representation for the sequence of the Fibonacci numbers? The answer is, fortunately enough, positive. Suppose that the Fibonacci numbers are denoted by hF0, F1, F2,..., Fi ,...i. Then, if there exists a function F (x) with such numbers as the 2 P∞ i coecients of powers of x, we would have F (x) = F0+F1x+F2x +··· = F0+F1x+ i=2 Fix . Using the fact that for i ≥ 2 we have Fi = Fi −1 + Fi −2, we have ∞ ∞ ∞ X i X i X i F (x) = F0 + F1x + (Fi −1 + Fi −2)x = F0 + F1x + Fi −1x + Fi −2x . i=2 i=2 i=2 Therefore, we have  ∞   ∞  X i  2 X i  F (x) = F0 + F1x + x  F x  + x  F x  .  i   i  i=1 i=0 P∞ i P∞ i Since F0 = 0, we have i=0 Fix = i=1 Fix . Thus, if such a function F (x) exists, it must satisfy F (x) = 0 + x + xF (x) + x 2F (x), that is, F (x) − xF (x) − x 2F (x) = x, which means that F (x)(1 − x − x 2) = x, or, in other words, x (4) F (x) = . 1 − x − x 2 i We now one have to show that this is indeed a function whose coecient of x is Fi , and we are done showing that F (x) is the generating function of the Fibonacci numbers. One thing worth trying is to write the generating function F (x) of the Fibonacci numbers as a sum of partial , since it is the of two polynomials. As a rst step, we can try to factor the denominator, which is a quadratic polynomial. Finding the p √ roots of 1−x −x 2 = 0 can be accomplished as x = (1± 1 − 4(−1)(1))/−2 = (1± 5)/(−2). This means, in particular, that the polynomial 1−x −x 2 has (x+ϕ) as a factor. By performing long , we see that 2 (5) 1 − x − x = (x + ϕ)(−ϕˆ − x). Trying to rewrite (5) in a more “digestible way”, we have that " !#    2 DRAFTx   x  1 − x − x = (x + ϕ)(−ϕˆ − x) = ϕ + 1 (−ϕˆ) 1 +  , ϕ   ϕˆ that is, 2 1 − x − x = (−ϕϕˆ)(1 − ϕˆx)(1 − ϕx) = (1 − ϕx)(1 − ϕˆx), where the equalities are due to the facts stated in the previous section. In particular, we have found a very nice way of writing the denominator of (4) as a product of two simple linear factors on x. Thus, writing F (x) as a sum of partial fractions, we have, with α and α 0 being un- knowns, x α α 0 (−αϕˆ − α 0ϕ)x + (α + α 0) F (x) = 2 = + = , 1 − x − x (1 − ϕx) (1 − ϕˆx) (1 − ϕx)(1 − ϕˆx) ELEMENTARY RESULTS ON THE FIBONACCI NUMBERS 5 which gives rise to the following linear system on two variables α and α 0:  −αϕˆ − α 0ϕ = 1  , α + α 0 = 0 √ √ which, upon being solved, gives us α = 1/ 5 and α 0 = −1/ 5. Therefore, 0   x α α 1  1 1  F (x) = 2 = + = √  −  . 1 − x − x 1 − ϕx 1 − ϕˆx 5 1 − ϕx 1 − ϕˆx  √ We have already seen in Proposition 7 that ϕ − ϕˆ = 5, which means that we can write the generating function F (x) purely in terms of the golden ration and its conjugate:   1  1 1  F (x) =  −  . ϕ − ϕˆ 1 − ϕx 1 − ϕˆx  But since we already know the expansion of 1/(1 − qx) for any real q, we can use our knowledge here, to get:   1 X X  1 X X ϕi − ϕˆi F (x) =  (ϕx)i − (ϕˆx)i  = (ϕi − ϕˆi )x i = x i . ˆ   ˆ ˆ ϕ − ϕ i ≥0 i ≥0 ϕ − ϕ i ≥0 i ≥0 ϕ − ϕ This seems to indicate us that ϕi − ϕˆi Fi = , ϕ − ϕˆ and, as the reader can show by induction, this is, indeed, a “closed formula” for the i-th Fibonacci number, called Binet’s Formula. We state this here for further reference: Theorem 8 (Binet’s Formula for Fibonacci Numbers). For every i ≥ 0, we have that ϕi − ϕˆi Fi = . ϕ − ϕˆ 2.3.2. Innite Series involving the Fibonacci Numbers. It is interesting to see that a gener- ating function provides a compact way of representing a sequence of numbers and, by manipulations to that function, we can obtain manipulations to the sequence of numbers. There are many things more to be said about generating functions, but one remarkable fact is that, although generally only regarded formally, there are some cases when it is possible to use those functions “plugging in some numbers” in place of the placeholder variable, namely, when the series analytically converges to the generating function of the sequence. That is the case of the function F , when its variable is x = 1/2.2 Indeed, recalling that we can write F as a power series as: X∞ DRAFT2 3 i F (x) = F0 + F1x + F2x + F3x + ··· = Fix , i ≥0 we see that if x = 1/2, the we would have

1 1 1 X Fi F (1/2) = F0 + F1 + F2 + F3 + ··· = . 2 4 8 2i i ≥0 But since we also know that a closed form for F , we have that X F 1 1/2 i = F = = 2. 2i 2 1 − 1/2 − 1/4 i ≥0

2In general, the convergence of a power series is determined as an interval centered in a point, that is a ball in one-dimensional space. 6 ROGÉRIO THEODORO DE BRITO

2.4. Binet’s Formula, Characteristic Equations, and Fibonacci Numbers. If we look√ ˆ at Binet’s expression for the i-th√ Fibonacci number, the we can easily see that ϕ − ϕ = 5, and, since 5 > 4, we have that 5 > 2, that is, 1/(ϕ − ϕˆ) < 1/2, which is a constant factor that multiplies the dierence ϕi − ϕˆi . Numerically speaking, we get an approximation for ϕ ' 1.618033988 and for ϕˆ ' −0.618033988, which is another way to see something that we have already proved: that the golden ratio and its conjugate sum 1 and, as a consequence, they have exactly the same “fractional part” (see Proposition 7). Also, given that |ϕˆ| < 1, we have that ϕˆi is a quite rapidly decreasing function. Further- ϕi ϕˆi more, we soon see that Binet’s formula Fi = − has this second term considerably ϕ−ϕˆ ϕ−ϕˆ smaller than the rst as i increases and we compare it with the rst term. For this purpose, if we dene a function nint: R → Z that for each x ∈ R gives us the nearest to x, we have that ! ϕi Fi = nint √ , 5 for all i ≥ 0, which is another way to express the i-th Fibonacci number as a function of the golden ratio. If we had not seen the derivation of the formula in the previous section, but only saw the table for the rst Fibonacci numbers, we could still have guessed that, perhaps, they i could have an exponential growth. In fact, if we had a real number α such that α = Fi , the, for the general case, we would have that α i = α i −1 + α i −2, for all i ≥ 2. Se we would 2 obviously have α , 0, then this would mean that α = α + 1, for all i ≥ 2, upon division of both sides of the equation by α i −2. But solving the equation x 2 = x + 1 for x, we get, quite unsurprisingly, x = ϕ or x = ϕˆ. This is a standard technique for solving linear and homogeneous dierential equations: we nd, rst, its characteristic equation (in our case, x 2 = x + 1) and, given the initial conditions (for us, F0 = 0 and F1 = 1), try to nd a solution as a linear combination of the exponentials given by the solutions to the characteristic equation. 0 0 So, let’s try it here with our recent ndings: if F0 = xϕ + yϕˆ for reals x,y, and 1 1 F1 = xϕ + yϕˆ , then, solving the linear system  0 = 1x + 1y 1 = ϕx + ϕyˆ , we get x = −y, and thus, ϕx + ϕˆ(−x) = 1, that is, x (ϕ − ϕˆ) = 1, which yields x = 1/(ϕ − ϕˆ), and, as y = −x, y = −1/(ϕ − ϕˆ). This shows that i ˆi i i i i ϕ − ϕ Fi = xϕ + yϕˆ = x (ϕ − ϕˆ ) = , ϕ − ϕˆ which is, again, Binet’s formula,DRAFT for which we now know of a second derivation. 2.5. Lucas numbers (initial conditions: L1 = 1, L2 = 3). 2.5.1. Derivation of a formula for the Lucas Numbers from the characteristic equation and n n the initial conditions (Ln = ϕ + ϕˆ ).

3. Other Properties of the Golden Ratio 3.1. ϕn = ϕn−1 + ϕn−2.

3.2. Alternative denition of the Golden Ratio as limn→∞ Fn+1/Fn. 3.3. Irrationality proof of the Golden Ratio. 3.4. Exponential Growth of the Fibonacci Sequence: Θ(ϕ). ELEMENTARY RESULTS ON THE FIBONACCI NUMBERS 7

3.5. Description of the Golden Ratio as a Continued .

3.6. .

3.7. Golden Segment.

4. Algorithms for the Fibonacci Numbers It is quite easy to develop a computer program for calculating those numbers. We give a pseudo-code for such program, which is nothing more than a mere “transcription” of the denition given above.

Algorithm 1 Fibonacci-Rec(n) Input: An integer n ≥ 0. Output: The n-th number of the Fibonacci sequence. 1: if n ≤ 1 then 2: return n 3: else 4: return Fibonacci-Rec(n − 1) + Fibonacci-Rec(n − 2) 5: end if

This short algorithm correctly implements a procedure for calculating Fn given n, as it is obviously doing what the dening recurrence relation describes. Unfortunately, despite its simplicity, Fibonacci-Rec is not a “good way” of calculating Fn. More precisely, as we shall see in a latter section, the number of operations performed by Algorithm Fibonacci-Rec cannot be bounded (from above) by a polynomial in the input n. Remark 1. Actually, from a Computational Complexity [2, 3, 7] point of view, the number of steps should be counted as a function of the length of the input, which, in this case, is the number of bits used as input for n—without padding it with “spurious” zeros at the left, obviously.

5. “Appearances” of the Fibonacci Numbers 5.1. In Geometry.

5.1.1. Trigonometric functions. Here we present an elementary derivation of the values of π sin, and cos of multiples of 5 and, somewhat unexpectedly, these values of the trigono- metric functions are related to the golden ratio. It is evident that since bothDRAFTsin and cos are periodic functions with period 2π, and that symmetries can be exploited so that we can restrict ourselves to the interval [0, π ). Concretely, is is sucient to determine the values sin(kπ/5) and cos(kπ/5) for k = 0,...,√ 4. As the derivation of such√ values happens to make use of the golden ratio ϕ = (1 + 5)/2 and its conjugate ϕˆ = (1 − 5)/2, we briey summarize below some useful relations: • ϕ2 = ϕ + 1 and ϕˆ2 = ϕˆ + 1. • ϕϕˆ = −1 and its equivalent form ϕ = −1/ϕˆ. • ϕ + ϕˆ = 1 or ϕ = 1 − ϕˆ. For most of our work, we will also need the so-called “double angle formulas” for sine and cosine, which we collect here for future reference: • sin(2θ ) = 2 cosθ sinθ. • cos(2θ ) = cos2 θ − sin2 θ = 2 cos2 θ − 1 = 1 − sin2 θ. 8 ROGÉRIO THEODORO DE BRITO

2π/5

4π/5

0

6π/5

8π 5

Figure 1. A regular pentagon and its internal angles.

Now, on to our main task. To determine the values of both sine and cosine of multiples of π/5, we rst see that a regular pentagon has all its 5 internal angles measuring 2π/5. So, for θ = 2π/5, we can see, by the symmetry of walking both clockwise and counterclockwise on the pentagon of gure 1 we have that (6) sin(4θ ) = − sinθ. Also, using the double angle formulas repeatedly, we have: 2 (7) sin(4θ ) = 2 cos(2θ ) sin(2θ ) = 2(2 cos θ − 1)(2 cosθ sinθ ) 2 3 (8) = (2 cos θ − 1)(4 cosθ sinθ ) = 8 cos θ sinθ − 4 cosθ sinθ. From (6) and (8), we have 3 8 cos θ sinθ − 4 cosθ sinθ = − sinθ , or, rearranging the terms, 3 sinθ (8 cos θ − 4 cosθ + 1) = 0. 3 So, sinθ = 0 or 8 cos θ − 4 cosθ + 1 = 0. As θ = 2π/5 implies sinθ , 0, we must have that 8 cos3 θ − 4 cosθ + 1 = 0. Solving for cosθ, we get 3 (9) 8x − 4x + 1 = 0. It is not hard to solve (9): its only possible rational solutions are ±1, ±1/2, ±1/4, ±1/8. By 1 1 3 inspection, we have that x = 1/2 works: 8 8 − 4 2 + 1 = 0. So, 8x − 4x + 1 is a multiple of (x − 1/2) and, by the Euclidean algorithm, we have 8x 3 − 4x + 1 = (x − 1/2)(8x 2 + 4x − 2). If cosθ = 1/2, then we know that θ = π/3 or that θ = 5π/3, which is not the case, as we know that θ = 2π/5. 2 We√ can nd the roots of 8x√ + 4x − 2 by the quadratic formula, which gives us x = −(1 + 5)/4 = −ϕ/2 or x = ( 5 − 1)/4 = −ϕˆ/2. In other words, cosθ = −ϕ/2 < 0 or cosθ = −ϕˆ/2 > 0. As cosθ must be positive, we must have cos(2π/5) = −ϕˆ/2. From the double angle formula for cosine, we have cos(4π/5) = 2 cos2(2π/5) − 1 = 2 2 2DRAFT 2((ϕˆ/2) ) − 1 = ϕˆ /2 − 1. As ϕˆ = ϕˆ + 1, we have cos(4π/5) = (ϕˆ + 1)/2 − 1 = (ϕˆ − 1)/2 = −ϕ/2. So far, we have determined cos(2π ) and cos(4π ). 5.1.2. Pentagons. 5.2. In Typography. 5.2.1. Page Layout. 5.3. In Music. 5.3.1. Béla Bartók? 5.3.2. Tool/Lateralus. ELEMENTARY RESULTS ON THE FIBONACCI NUMBERS 9

6. The Fibonacci numbers and their siblings 6.1. Relation with binomial coecients. 6.1.1. Relations between the Fibonacci Numbers and the Lucas Numbers. 6.2. Negative index Fibonacci Numbers. 6.3. Other relations found in the Book of Andrews [1].

7. Fibonacci Numbers and Linear Algebra

Use of the matrix " # 1 1 , 1 0 its eigenvectors, its eigenvalues, its diagonal matrix, its powers, its determinants, more relations of Fibonacci Numbers, vectors that are neatly transformed by this matrix etc.

8. Fibonacci Numbers and Their use in Analysis of Algorithms 8.1. Iterative Algorithm for the Computation of Fibonacci Numbers. 8.2. Analysis of the Recursive Algorithm for the Fibonacci Numbers. 8.3. Euclid’s Greatest Common Algorithm. Now that we know some prop- erties of the divisibility relation, we can dene a very useful concept that is a consequence of division. Denition 2 (Greatest Common Divisor). Let a and b be integers not both null. An integer d that divides a and b simultaneously (i.e., d | a and d | b) is called a common divisor of a and b. If a common divisor d of a and b is such that every common divisor d 0 of a and b also divides d, then we say that d is a greatest common divisor of a and b. We denote that d is a greatest common divisor of a and b by d = (a, b). If d = 1, then we say that a and b are coprime or relatively prime. Notice that, by the denition above, if d and d 0 are both greatest common of a and b, then, in particular, d | d 0 and d 0 | d and by the previous proposition, d = ±d 0, i.e., two greatest common divisors of a and b dier only by their signal. It is customary to dene the greatest common divisor by taking the positive integer between d and d 0 and we shall, from now on, adopt this convention. From this it should be obvious that (a, b) = (−a, b) = (|a|, |b|) and that (a, b) = (b, a). The reader has certainly noticed that two numbers a and b do have a greatest common divisor: since 1 | a and 1 | b, in the worst case, their greatest common divisor is 1. But how can (a, b) be calculated? One method is to compute the sets D(a) and D(b) of positive divisors of a and b, respectively, take the intersection D(a) ∩ D(b), and nd its maximum element (it is obvious that suchDRAFT set is bounded from above and that their intersection is non-empty). Example 1. To calculate (24, 15), can see that D(24) = {1, 2, 3, 4, 6, 8, 12, 24} and D(15) = {1, 3, 5, 15}. Therefore, D(24) ∩ D(15) = {1, 3} and from this we conclude that (24, 15) = 3. It is obvious that this process can become fantastically slow depending on a and b. But there is a much faster method known since the ancient Greeks (circa 350 B.C.) called Euclid’s Greatest Common Divisor Algorithm. We need a simple proposition before proceeding with the study of greatest common divisors: Proposition 9 (The Division Algorithm). Let a and b be integers, with b a positive integer. Then, there exist integers q and r, such that a = bq + r, with 0 ≤ r < b. Furthermore, the integers q and r above are unique. 10 ROGÉRIO THEODORO DE BRITO

Proof. Let us consider the set S = {a − bx : x ∈ Z}. Notice that S has positive elements (it suces to take x small enough). Let r be the smallest non-negative element of S.3 We claim that r = a − bq is such that 0 ≤ r < b. In fact, if r ≥ b, then we would have r − b ≥ 0 and r − b would be non-negative and of the form a − bq − b = a − b(q + 1), that is, a member of the set S strictly smaller than r, which would contradict the minimality of r. To prove the uniqueness, let us suppose that a = bq + r = bq0 + r 0, with 0 ≤ r , r 0 < b. Then we have that bq − bq0 = r 0 − r, that is b(q − q0) = r 0 − r. Without any loss of generality, we may assume that r 0 ≥ r, from which it follows that b ≥ b − r > r 0 − r ≥ 0, that is, b > r 0 − r ≥ 0. Then we have r 0 − r being both a non-negative multiple of b and strictly less than b, from which it follows that r 0 − r = 0, i.e., r 0 = r. Since b , 0, we have q − q0 = 0, i.e., q = q0 and the uniqueness is established. 

Denition 3 (Quotient, Remainder). With the notation of the lemma above, the integer q is called the quotient of a divided by b and r is called the remainder of a divided by b.

The proposition above tells us, intuitively, how to nd divisibility with “remainder”, that is, when b - a, we still can write a as a multiple of b plus a “small correction” (less than b). As another remark, notice that, in the statement of the proposition, if we had b < 0, then we could apply it for b0 = −b and we would obtain a pair of numbers q0, r 0 such that a = q0b0 + r 0, with 0 ≤ r 0 < |b|.

Example 2. We had seen earlier that 4 - 6 as we can’t write 6 = 4a for any integer a. But as a “consolation prize”, we can see that 6 = 4 · 1 + 2 and here 2 is the “adjustment” to 4 · 1 so that we can have “an approximation” to the assertion that 4 divides 6. On the other hand, if a | b, we have b = ac, with a remainder of 0.

Back to the subject of greatest common divisors, Euclid’s Algorithm is based on the following observation: if a can be written in the form a = bq +r, then any common divisor of a and b is also a divisor of r, since r = a − bq. Conversely, if b and r share a common divisor, then it must also divide a. This means that the set of common divisors of a and b is precisely the set of common divisors of b and r, and their maximum must be the same or, in other words, (a, b) = (b, r ). Furthermore, if we can have 0 ≤ r < b (which we can by Proposition 9), then the problem of nding (a, b) is reduced to the problem of nding the greatest common divisor of a pair of numbers where one of them is strictly smaller than the other, which means that we are faced with a “simpler” problem. Now, explicitly, if we have:

a = bq1 + r1, 0 < r1 < b, (a, b) = (b, r1) b = r1q2 + r2, 0 < r2 < r1, (b, r1) = (r1, r2) r1 = r2q3 + r3, 0 < r3 < r2, (r1, r2) = (r2, r3) (10) . DRAFT. . . . .

rn−2 = rn−1qn + rn , 0 < rn < rn−1, (rn−2, rn−1) = (rn−1, rn )

rn−1 = rnqn+1 + 0, (rn−1, rn ) = (rn , 0), then we see that performing multiple divisions, until we get a remainder equal to 0, we can determine the greatest common divisor of two integers to be equal to (rn , 0) = rn. This practical device allows us to calculate (a, b) quite quickly, as we shall see when we analyze its computational complexity.

3Here we use the fact that a set of non-negative integers is well-ordered, that is, a non-empty set of non- negative integers has a smallest element. ELEMENTARY RESULTS ON THE FIBONACCI NUMBERS 11

Example 3. As before, let us determine the (24, 15), now with the assistance of Euclid’s Algorithm. We have: 24 = 15 · 1 + 9 15 = 9 · 1 + 6 9 = 6 · 1 + 3 6 = 3 · 2, and from just 4 divisions we conclude that 3 = (24, 15). This algorithm can be easily implemented in a digital computer with use of a modern computer language with the pseudocode given by Algorithm gcd.

Algorithm 2 gcd (a, b) Input: Two positive integers a and b. Output: Their greatest common divisor. while b , 0 do r ← a mod b // mod represents the remainder of a divided by b a ← b b ← r end while return a

8.3.1. Lamé’s Theorem. According to Alexander Schrijver, the theorem below (given by the French mathematician Gabriel Lamé, in a paper published in 1884) was one of the rst conscious analysis of time requirements of an algorithm. [7, p. 14]. Theorem 10 (Lamé’s Theorem). Let a and b be positive integers. Then, the number of divisions performed by Euclid’s Algorithm applied to a and b is at most 5 times the number of digits used in the representation of b.

Proof. Going back to the successive equations (10), we see that rn ≥ 1. From rn−1 = rnqn+1, we have that rn−1 ≥ 2, since rn−1 > rn. This means that rn ≥ F2 and rn−1 ≥ F3. But then, rn−2 = rn−1qn + rn ≥ F3 + F2 = F4, since qn ≥ 1. Similarly, rn−3 = rn−2qn−1 + rn−1 ≥ F4 + F3 = F5, since qn−1 ≥ 1. By induction, we can see that

(11) rn−k ≥ Fk+2, for k = 0,..., n. 2 − − On the other√ hand, let us consider the positive root of the equation x x 1 = 0, 1+ 5 which is ϕ = 2 , the golden ratio. We see that: 2 ϕ = ϕ + 1 < 2 + 1 ≤ F3 + F2 = F4 3 DRAFT2 ϕ = ϕ + ϕ < F4 + 2 ≤ F4 + F3 = F5 4 3 2 ϕ = ϕ + ϕ < F5 + F4 = F6. In general, we have k (12) ϕ < Fk+2, for k ≥ 2. k Then, by equations (11) and (12), we have ϕ < Fk+2 ≤ rn−k , that is k ϕ < rn−k . n n In particular, ϕ < rn−n = r0 = b, that is, ϕ < b. As log10 is a monotonically increasing function, we have that n log ϕ < log b, i.e., n < log10 b . As log ϕ ' 0.20898764 > 10 10 log10 ϕ 10 1 0.2 = 5 , n < 5 · log10 b. 12 ROGÉRIO THEODORO DE BRITO

s If b has s digits in its decimal representation, b < 10 , that is log10 b < s, and, therefore, n < 5s, from where it follows that the number n+1 of divisions performed by the Euclidean Algorithm is n + 1 ≤ 5s, which proves the theorem.  Despite being one of the rst algorithms ever described (which Donald Knuth calls “the granddaddy” of all algorithms [6, p. 335]) and having the quality of requiring only a polynomial number of steps in its execution (in terms of its input length), it is not, in general, the fastest way of nding the greatest common divisor of two integers. Faster methods for modern computers include Derrick H. Lehmer’s algorithm and Josef Stein’s “binary method”. 8.4. Data Structures: Fibonacci Heaps.

References [1] G. E. Andrews, Number Theory, Dover Publications, Inc., 1st ed., 1994. Cited in sections 1 and 9. [2] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to Algorithms, the MIT Press, 2nd ed., 2001. Cited in sections 1 and 7. [3] M. R. Garey and D. S. Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness, W. H. Freeman and Company, 1st ed., 1979. Cited in section 7. [4] R. L. Graham, D. E. Knuth, and O. Patashnik, Concrete Mathematics, Addison-Wesley, Inc., 2nd ed., 1994. Cited in section 1. [5] H. L. Guidorizzi, Um Curso de Cálculo, vol. 1, Livros Técnicos e Cientícos Editora, 2nd ed., 1989. Cited in section 3. [6] D. E. Knuth, The Art of Computer Programming: Seminumerical Algorithms, vol. 2, Addison-Wesley, Inc., 3rd ed., 1998. Cited in section 12. [7] C. H. Papadimitriou, Computational Complexity, Addison-Wesley, Inc., 1st ed., 1994. Cited in sections 7 and 11. [8] H. S. Wilf, generatingfunctionology, Academic Press, Inc., 2nd ed., 1994. Cited in section 3.

DRAFT