Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use MATLAB codes to answer this question Write a function prodofk that will receive two positive integers n and k and will calculate and

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

please use MATLAB codes to answer this question

Write a function prodofk that will receive two positive integers n and k and will calculate and return the product of the firstk odd integers from 1 to n. Use a loop. If the value of n does not allow for k odd integers, then the function should return the value 0. >> prodofk(11, 3) ans - 15 >prodofk(11, 11) ans - For example: Test assert (prodofk(25, 5)945) assert (prodofk(7,2)3) Result assert (prodofk(25, 5) = 945) assert (prodofk(7,2)3) assert (prodofk(7,5) = 0) assert (prodofk (8,5) 0) Answer: (penalty regime: 0 %) 1 Function value -prodofk(n,k) 2 i-0; 3 m-1; 4 value-1 5 while m

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions