The abundancy index of a number is the ratio of the sum of its factors to the number itself.
For example a(12)=σ(n)/n=(1+2+3+4+6+12)/12 = 28/12 = 7/3.
Two numbers n and m are said to be friends if a(n)=a(m). Numbers that have at least one friend are called friendly numbers. Numbers with no friends are called solitary.
Task 1: Find at least one friend for the number 12.
Task 2: Prove there is a set of at least 50 mutual friends.
Task 3: Prove if the fraction σ(n)/n cannot be reduced then n is solitary.
Task 4: a(18)=39/18 which does reduce to 13/6. Prove 18 is solitary nevertheless.
Quite a few numbers have unknown status. The smallest of which is 10. I won't ask you to prove the status of any of these.
234 is a friend of 12
abundancy(12) = '7/3'
abundancy(234) = '7/3'
----
def sumfactors(n):
""" for integer n, return a list of all the factors including 1 and n """
ans = [1,n]
for i in range(2,2+int(n**.5)):
if n%i == 0:
ans.append(i)
ans.append(int(n/i))
return sum(set(ans))
def abundancy(n):
""" start with an integer, convert to string version of
simplest fraction of a(n)/n """
if n == 0:
return '0/1'
s = sumfactors(n)
g = gcd(s,n)
numer = int(s/g)
denom = int(n/g)
return str(numer) + '/' + str(denom)
|
Posted by Larry
on 2023-06-02 11:50:34 |