Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Answer by using matlab Double factorial (denoted as n!!) is defined as the product of all integers from 1 to n (where n is a
Answer by using matlab
Double factorial (denoted as n!!) is defined as the product of all integers from 1 to n (where n is a nonnegative integer) that have the same parity (whether odd or even) as n For n is even: n!!= || (2k)= (2)(4)... (n 4)(n 2)(n) 1/2 k=1 . e.g.6!!= (2)(4)6) = 48 For n is odd: n+ n!!= II (2k 1)= (1)(3)...(n - 4)(n 2)(n) k=1 e.g. 5!!=(1)(3)(5) = 15 MACHINE PROBLEM Make a script file that will evaluate the double factorial of a non- negative integer n. The following are the conditions to be satisfied: [1] The program must ask the user to input a non-negative integer n (assumed to be always correct) [2] The program will test whether the input is odd or even. The program is not allowed to use rem and prod commands or any built-in commands that has not yet been discussed EXCEPT mod. [3] O!! and 1!! are special allowable inputs with a value of 1. (Hint: Use if...end) [4] The program must show the following output where n is arbitrary: >>This program will solve n!! >>Please enter a non-negative integer n: 6 (example only) The value of 6!! is 48. (Hint: use 2- %d) [5] Upload the .m file along with its screenshot on the content provided. [6] Upload the screenshots of two simulated outputs, one for n =even and one for n=oddStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started