Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fermat’s Little Theorem Fibonacci Numbers Shirley Moore CS4390/5390 Fall 2013 September 10, 2013 1.

Similar presentations


Presentation on theme: "Fermat’s Little Theorem Fibonacci Numbers Shirley Moore CS4390/5390 Fall 2013 September 10, 2013 1."— Presentation transcript:

1 Fermat’s Little Theorem Fibonacci Numbers Shirley Moore CS4390/5390 Fall 2013 http://svmoore.pbworks.com/ September 10, 2013 1

2 Agenda Fermat’s Little Theorem (20 min) Answer questions about homework (10 min) Fibonacci numbers (45 min) Wrapup (5 min) 2

3 Learning Outcomes After completing this lesson, you should be able to – State Fermat’s Little Theorem – Use Fermat’s Little Theorem to compute a large exponential in modular arithmetic – Use Fermat’s Little Theorem to prove a number is not prime – Write a Matlab function to compute a number sequence and analyze its runtime – Hypothesize and prove properties of a number sequence 3

4 Fermat’s Little Theorem First stated by Pierre de Fermat in 1640 First published proof by Leonhard Euler in 1736 Highly useful for simplifying the computation of exponents in modular arithmetic Corollary by Euler serves as the basis for RSA encryption Theorem: If p is a prime number and p does not divide a, then a p-1 1 (mod p) Example: p = 5 Proof: See http://www.youtube.com/watch?v=w0ZQvZLx2KA Use FLT to find 3 100,000 (mod 53) 4

5 Use FLT to prove a number is composite without factoring it To prove n is composite, find some a such that a is not a multiple of n and a n-1 ≠ 1 (mod n). Is 91 a prime number? Try a = 2. 7 5 = 1 (mod 6), so is 6 prime? True or False: If b n-1 = 1 (mod n) for all b such that b is not a multiple of n, then n is prime. 5

6 Modular Arithmetic in Matlab http://www.mathworks.com/help/symbolic/m upad_ug/modular-arithmetic.html http://www.mathworks.com/help/symbolic/m upad_ug/modular-arithmetic.html mod mods powermod OK to use powermod for Problem 5 on Homework 1 See also www.wolframalpha.comwww.wolframalpha.com 6

7 Fibonacci Sequence A man puts a pair of rabbits in a place surrounded on all sides by a wall. How many pairs of rabbits can be produced from that pair in a year if it is supposed that every month each pair begets a new pair which from the second month on becomes productive? --Leonardo Pisano Fibonacci, Liber Abaci, 1202 f n = f n-1 + f n-2 f 0 = 0, f 1 = 1 7

8 In-Class Exercises 1.Write a recursive Matlab function to compute the first n Fibonacci numbers. What is the time complexity of your algorithm? 2.Write an iterative Matlab function to compute the first n Fibonacci numbers. What is the time complexity of your algorithm? 3.Write a matrix formulation of the iterative algorithm. 8

9 Exercises (cont.) 4.Plot the first 25 Fibonacci numbers versus n. 5.Plot the first 25 Fibonacci numbers versus n on a semilog scale. 9

10 Greatest Common Divisor (GCD) of Fibonacci Numbers For m, n ≥ 1, gcd(f m,f n ) = f gcd(m,n) Proof: left as an exercise Example: f 34 = 5702887 f 51 = 20365011074 What is gcd(f 34,f 51 ) ? Corollary 1: Two consecutive Fibonacci numbers are relatively prime. Corollary 2: F k divides evenly into F nk. 10

11 GCD of Fibonacci Numbers (cont.) Which Fibonacci numbers are even? Which Fibonacci numbers are multiples of 3? Which Fibonacci numbers are multiples of k? 11

12 Binet’s Formula where τ is the golden ratioand σ = -1/τ. Proof: by induction Corollary: F n equals the nearest integer to 12 Exercise: 6. How many digits are in F 1000 and what are the first few digits?

13 More Exercises 7.Investigate the ratio F n+1 /F n of consecutive Fibonacci numbers and try to identify the limit. 8.Investigate the sum F 0 + F 1 + … + F n. Find a formula for this sum and prove it by induction. 9.Investigate the numbers F n-1 x F n+1. Find a formula for this product and prove it. 10.Find all n between 1 and 100 for which F n is prime. Do you see any patterns? 13


Download ppt "Fermat’s Little Theorem Fibonacci Numbers Shirley Moore CS4390/5390 Fall 2013 September 10, 2013 1."

Similar presentations


Ads by Google