140 likes | 572 Views
Fermat’s Little Theorem Fibonacci Numbers. Shirley Moore CS4390/5390 Fall 2013 http://svmoore.pbworks.com/ September 10, 2013. Agenda. Fermat’s Little Theorem (20 min) Answer questions about homework (10 min) Fibonacci numbers (45 min) Wrapup (5 min). Learning Outcomes.
E N D
Fermat’s Little TheoremFibonacci Numbers Shirley Moore CS4390/5390 Fall 2013 http://svmoore.pbworks.com/ September 10, 2013
Agenda • Fermat’s Little Theorem (20 min) • Answer questions about homework (10 min) • Fibonacci numbers (45 min) • Wrapup (5 min)
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
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 ap-1 1 (mod p) • Example: p = 5 • Proof: See http://www.youtube.com/watch?v=w0ZQvZLx2KA • Use FLT to find 3100,000 (mod 53)
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 an-1 ≠ 1 (mod n). • Is 91 a prime number? Try a = 2. • 75 = 1 (mod 6), so is 6 prime? • True or False: If bn-1 = 1 (mod n) for all b such that b is not a multiple of n, then n is prime.
Modular Arithmetic in Matlab • http://www.mathworks.com/help/symbolic/mupad_ug/modular-arithmetic.html • mod • mods • powermod • OK to use powermod for Problem 5 on Homework 1 • See also www.wolframalpha.com
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 fn = fn-1 + fn-2 f0 = 0, f1 = 1
In-Class Exercises • Write a recursive Matlab function to compute the first n Fibonacci numbers. What is the time complexity of your algorithm? • Write an iterative Matlab function to compute the first n Fibonacci numbers. What is the time complexity of your algorithm? • Write a matrix formulation of the iterative algorithm.
Exercises (cont.) • Plot the first 25 Fibonacci numbers versus n. • Plot the first 25 Fibonacci numbers versus n on a semilog scale.
Greatest Common Divisor (GCD) of Fibonacci Numbers For m, n ≥ 1, gcd(fm,fn) = fgcd(m,n) Proof: left as an exercise Example: f34 = 5702887 f51 = 20365011074 What is gcd(f34,f51) ? Corollary 1: Two consecutive Fibonacci numbers are relatively prime. Corollary 2: Fk divides evenly into Fnk.
GCD of Fibonacci Numbers (cont.) • Which Fibonacci numbers are even? • Which Fibonacci numbers are multiples of 3? • Which Fibonacci numbers are multiples of k?
Binet’s Formula where τ is the golden ratio and σ = -1/τ . Proof: by induction Corollary: Fn equals the nearest integer to Exercise: 6. How many digits are in F1000 and what are the first few digits?
More Exercises • Investigate the ratio Fn+1/Fn of consecutive Fibonacci numbers and try to identify the limit. • Investigate the sum F0 + F1 + … + Fn. Find a formula for this sum and prove it by induction. • Investigate the numbers Fn-1 x Fn+1. Find a formula for this product and prove it. • Find all n between 1 and 100 for which Fn is prime. Do you see any patterns?