Problem 1 (10 pts) Write a MATLAB function named get_fact that accepts a non-neg
ID: 3677054 • Letter: P
Question
Problem 1 (10 pts) Write a MATLAB function named get_fact that accepts a non-negative integer, n (n 0) and returns the factorial, n!, of that number using a forloop.
Problem 2 (10 pts) Write a MATLAB function named get_fib that accepts a non-negative integer, k (k 0) and returns the corresponding term, Fk, of the Fibonacci sequence using a while loop.
Problem 3 (20 pts) Looking closely at the infinite series, it would be reasonable (and correct) to conclude that it diverges. However, it may be surprising that the similar infinite series does not diverge, instead converging to a number (albeit irrational): .
In similar fashion, when reciprocals of the factorials are added together, they also produce a series that converges to an important (and irrational) number with which you are probably familiar: e (Euler’s number).
Another convergent series is that of the reciprocals of the Fibonacci numbers, which sum to produce another irrational number called the reciprocal Fibonacci constant, or . (Note that the Fibonacci series—and thus —are intimately related to the golden ratio, 1.61803.)
(a)Write a MATLAB script named that calls your function to estimate e.
(b)Write a MATLAB script named that calls your function to estimate .
Your estimates must be to at least 10 decimal places. (Hint: You’ll need to set atolerance to tell your
program when to exit the loop and return its estimate.)
Explanation / Answer
1.
end
2.
3.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.