Question: 2. Using your favorite programing language (Matlab, Python, C, C++,...) compute the first 1000 elements of the Fibonacci sequence f(n) = f(n-1)+f(n-2) where f(1) =

2. Using your favorite programing language (Matlab, Python, C, C++,...) compute the first 1000 elements of the Fibonacci sequence f(n) = f(n-1)+f(n-2) where f(1) = f(2) = 1. Determine the first digit of each element. Find the histogram of the first digit. That is, find the fraction p(k) of the first digits that are k = 1, 2, ..., 9. Hint: In Matlab the function "hist" could be useful. Compare with log1((k + 1)/k), for k = 1, ...,9. You should produce a table like below. K p(k) log10 ((k + 1)/ k) 1 2 3 6 -J OO 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
