MATLAB. The factorial product of all positive integers less than or equal to 150 Create a script to calculate the factorial of 150 using loops and conditionals. Do not use MATLAB built in function for factorials.
Added by Ryan B.
Step 1
We need to initialize a variable to store the factorial value. Let's call it "fact" and set it to 1. Show more…
Show all steps
Your feedback will help us improve your experience
Nicholas Mogoi and 74 other Physics 102 Electricity and Magnetism educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Create a Matlab program that computes the factorial of a number (n). This program may be done using either a for or a while loop. This is how factorial works: 0! = 1 1! = 1 2! = 1 * 2 = 2 3! = 1 * 2 * 3 = 6 4! = 1 * 2 * 3 * 4 = 24 5! = 1 * 2 * 3 * 4 * 5 = 120 Evaluate the program for n = 5, n = 7, and n = 10. Show the results as: "The factorial of n is [result]". Do not use the built-in function for factorial.
Carson M.
Write a MATLAB script file to approximate the function f(x) = e^x with a Taylor series. The function f(x) = e^x can be approximated by the following Taylor series: e^x ≈ 1 + x + (x^2)/2! + (x^3)/3! + (x^4)/4! + ... Keep in mind that the "!" symbol denotes factorial. For example, the factorial of 4 = 4! = 1 * 2 * 3 * 4. MATLAB has a built-in factorial command that can be used. In a script file, prompt the user for the value of the exponent x as an integer (in terms of the function e^x). Then, with a "while" loop, calculate the approximate value of e^x using the above Taylor series. The output message should display "The approximate value of e^x is XX.XXXXXX", where XX.XXXXXX is the numeric value displayed to 6 decimal places. The output value should be correct (or exactly match your calculator's output of e^x) up to 6 decimal places.
Sri K.
(Factorials) Factorial calculations are common in probability. The factorial of a nonnegative integer n is written n! (pronounced "n factorial") and is defined as follows: n! = n * (n - 1) * (n - 2) * ... * 1 for values of n greater than or equal to 1, with 0! defined to be 1. So, 5! = 5 * 4 * 3 * 2 * 1 which is 120. Factorials increase in size very rapidly. Write a script that inputs a nonnegative integer and computes and displays its factorial. Try your script on the integers 10, 20,
Supreeta N.
Recommended Textbooks
University Physics with Modern Physics
Physics: Principles with Applications
Fundamentals of Physics
Watch the video solution with this free unlock.
EMAIL
PASSWORD