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

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 myprod

Explanation / 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

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