Mar-10-2021, 10:36 AM
(This post was last modified: Mar-10-2021, 10:36 AM by Serafim.
Edit Reason: Corrected an error
)
A couple of more sequences:
Interestingly, I found an algorithm on GeeksForGeeks but it is incorrect.
def arithmetic(n): # https://en.wikipedia.org/wiki/Arithmetic_number seq = [] x = 1 while len(seq) < n: divisors = [i for i in range(1,x+1) if not x % i] if sum(divisors) % len(divisors) == 0: seq.append(x) x += 1 return seq def deficient(n): # https://en.wikipedia.org/wiki/Deficient_number seq = [] x = 1 while len(seq) < n: divisorsum = sum([i for i in range(1,x+1) if not x % i]) if divisorsum < 2 * x: seq.append(x) x += 1 return seq def abundant(n): # https://en.wikipedia.org/wiki/Abundant_number seq = [] x = 1 while len(seq) < n: divisorsum = sum([i for i in range(1,x+1) if not x % i]) if divisorsum > 2 * x: seq.append(x) x += 1 return seqI'm going to skip "untouchable numbers" for now as I don't find a good algorithm. The only implementation so far is not in Python and it is also prohibitively slow for numbers above 5. Maybe later, I do have a couple of ideas ...
Interestingly, I found an algorithm on GeeksForGeeks but it is incorrect.