Amicable Number

version 1.0.0.0 (1.27 KB) by Abhisek Ukil
Function to compute amicable pairs between two intergers, upper & lower limits.

889 Downloads

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.

Check: http://en.wikipedia.org/wiki/Amicable_number

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:
output=amicable(N2,N1)

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 (2022). Amicable Number (https://www.mathworks.com/matlabcentral/fileexchange/21484-amicable-number), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories

Community Treasure Hunt

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

Start Hunting!