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

Computer coding It is often certain criteria so that you can necessary to find v

ID: 3825732 • Letter: C

Question

Computer coding It is often certain criteria so that you can necessary to find values in a data set that meet program calculations with only those data. For problem, you will design and write a Matlab both a this that finds the n smallest natural numbers (positive integers that are evenly divisible by and (where n, a and b are also numbers. It calculate and port (to two should also decimal places) the sum of the squareroot s of the numbers meeting the criteria. The program must work for any n, a and provided by the user. The only built-in function (other than standard mathematical operators) that you may use in your design is the rem function, which calculates the remainder after division. Specifically, rem(x, y) returns the remainder of x divided by y. In your program, design a user-defined function to perform the needed selection and calculations, but use a parent script to get input and provide results to user (and call the function).

Explanation / Answer

function myfunction(n,a,b)
k=0;
i=0;
sum=0;
while i<n
if rem(k,a)==0 && rem(k,b)==0
sum = sum+sqrt(k);
i=i+1;
disp 'The numbers are '
disp (k)
end
k=k+1;
end
disp 'Sum of square roots is'
disp (sum)

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