A pair of distinct integers is considered amicable if the sum of proper divisors for one number equals the second and vice versa.
Example: 220, 284
220=2^2*5*11 (1+2+4+5+10+11+20+22+44+55+110 = 284)
284=2^2*71 (1+2+4+71+142 = 220)
Consider the ratio of the sum of the divisors of a natural number by the number itself, R(n). If two distinct natural numbers have equal ratios, those numbers are said to be "friendly".
Example: 30, 140
R(30) = (1+2+3+5+6+10+15+30)/30 = 12/5
R(140) = (1+2+4+5+7+10+14+20+28+35+70+140)/140 = 12/5
Problem: Write a threaded application to find and print each pair of amicable numbers and each pair of friendly numbers that are both within the given input range. The range, two positive integers, is to be given to the application as it begins execution, nominally as command line arguments.
Example execution:
> amicable.exe 200 600
220 and 284 are AMICABLE
240 and 600 are FRIENDLY
Restrictions: No direct knowledge or information may be encoded into the source files or auxiliary files used by the applications. For example, no tables of prime numbers or lists of amicable numbers or friendly numbers may be used. All such information must be generated by the application at run-time.
Tags: