Write a script that will calculate the product of the odd integers from 1 to n (
ID: 3754418 • Letter: W
Question
Write a script that will calculate the product of the odd integers from 1 to n (or from 1 to n-1 if n is even, where n is some integer> 3) and store the result in the variable myprod". Use a for loop Please do not change the provided variable names, and make sure to store the calculated product in the variable "myprod Your Script C Reset MATLAB Documentation 1 s Pick a value 21 n = ? for n greater than 3 41% calculate the product of all the odd integers from 1 to n s(using a for loop) and store it in "myprod" a myprodExplanation / Answer
MATLAB CODE:
n=input('Enter n value greater than 3:');
myprod=0;
if n>3
for i=1:n
if mod(i,2)~=0
myprod=myprod+i;
end
end
else
display('n should be greater than 3');
end
prompt='sum of odd integers is';
display(prompt);
myprod
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.