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

First, please write a MATLAB function that finds all the divisors between 2 and

ID: 1840534 • Letter: F

Question

First, please write a MATLAB function that finds all the divisors between 2 and 20 of an integer. Your function header should be function div = finddi visor (a) when' the input a is an integer, the output div is a. vector that contains all of the divisors of a that are between 2 and 20. For example, if the input is 42, its divisors between 2 and 20 are 2,3,6,7,12.14 18 (21 is also a divisor of 42, but larger than 20, so does not count here') The rmtrmt should be div = [2 3 6 7 12 14 18], P Once you construct your MATLAB function fmddivisor, use it to find all the divisors (between 2 and 20) of your WSU student ID number.

Explanation / Answer

main program:

clc
clear all
a=input('enter any integer');
[div]=finddivisor(a)

sub function:

function [div] = finddivisor(a)
c=1;
for i=2:1:20
if (rem(a,i)==0)
div(c)=i;
c=c+1;
end
end