Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB function named get_fac that accepts a non-negative integer, n (n

ID: 3673930 • Letter: W

Question

Write a MATLAB function named get_fac that accepts a non-negative integer, n (n > 0) and returns the factorial, n!. of that number using a far loop. Write a MATLAB function named get_fib that accepts a non-negative integer, k (k > 0) and returns the corresponding term. F_k, of the Fibonacci sequence using a while loop. Looking closely at the infinite series summation_n = 1^infinity 1/n, it would be reasonable (and correct) to conclude that it diverges, However, it may be surprising that the similar infinite series summation_n = 1^infinity 1/n^2 does not diverge, instead convening to a number (albeit irrational):pi^2/6 1.645. 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 (As an aside, note that the Fibonacci serie-and thus -are intimately related to the golden ratio, 1.61803.) Write a MATLAB script named PPl_P3a that calls your function get_fac to estimate e. Write a MATLA B script named PP 1_P 3b that calls your function get_f ib to estimate Your estimates must be to at least 10 decimal places.

Explanation / Answer

Multiple Questions : ANswering 1st.

function fact = get_fac(n)
f = 1;
for i = 1:n
    f = f*i;
end
fact = f;
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote