MATLAB: Finding the divisors for a number displaying the divisors between two numbers.

divisors

I am trying to find the divisors of a number say 84 and I need to show the divisors from 2 to 20 so if the divisors are div=[1 2 3 6 7 14 21 42 84] how can I show the selected numbers between the numbers 2 and 20 (2</= div >/=20) so I get an answer of div=[1 2 3 6 7 14]
so far I have and I know this isnt right
%function div = finddivisor(a)
divisors(84)
disp(a>1)
disp(a<21)
this gets me close to my answer but i dont know how to get it into a form that shows the divisors alone

Best Answer

See this question:
>> N = 84;
>> V = 2:20;
>> D = V(rem(N,V)==0)
D =
2 3 4 6 7 12 14