# divisor(n)

Version 1.1.0.0 (1.69 KB) by
Calculate the distinct divisors of a number not just the prime factors.
Updated 28 Jun 2009

divisor(n) : row vector of all distinct divisors of a positive integer N, including 1 and N.

Remark:
This function uses the default factor() routine in Matlab and hence is limited to input values up to 2^32. However if factor() routine does get updated for larger integers, this function will still work fine. Alternately you may comment out the statement that compares the values to 2^32, the factor() routine will work just fine (except maybe it will be bit slower for big numbers).
Using factor() provides a significant speed improvement over manually searching for the each divisor of n.

Example:
a = divisor(12);
returns -> a = [1, 2, 3, 4, 6, 12];

factor, primes

### Cite As

Yash (2024). divisor(n) (https://www.mathworks.com/matlabcentral/fileexchange/24500-divisor-n), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R10
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Categories
Find more on Calculus in Help Center and MATLAB Answers

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.1.0.0