Amicable Number

Function to compute amicable pairs between two intergers, upper & lower limits.
Updated 26 Sep 2008

No License

Amicable numbers are two different numbers so related that the sum of the proper divisors of the one is equal to the other, one being considered as a proper divisor but not the number itself. Such a pair is (220, 284); for the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, of which the sum is 284; and the proper divisors of 284 are 1, 2, 4, 71, and 142, of which the sum is 220.


This is a function to compute amicable pairs between two intergers, upper & lower limits. Put the 'amicable.m' file into your MATLAB path or working directory and call the following syntax.

Function syntax:

where, N2 is the upper limit and N1 the lower limit, both positive integers.

If only one number is given, it is considered to be the upper limit and
the default lower limit is then 220 (as no amicable pair exists below 220).
If two numbers are given, the upper limit (1st number) must be greater than
the lower limit (2nd number).

The 'output' would be a matrix having two columns, for the amicable pairs.
The rows show the unique pairs. If no such pairs are found empty matrix is returned.

Cite As

Abhisek Ukil (2024). Amicable Number (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Mathematics 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

Major upgrade to include the upper and lower limits, so that one can search for amicable pairs within these bounds, imrpoving the speed.