Aliquot Sums

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa® 365 Puzzlers  Calendar 2017

Mensa® 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

 

Problem Description

Here's a program to let you start exploring the interesting topic of Perfect, Amicable, and Sociable numbers.  They are defined by the sums of their aliquot divisors.  The aliquot divisors of a number are all of its divisors except the number itself.  The aliquot sum is the sum of the aliquot divisors so, for example, the aliquot divisors of 12 are 1, 2, 3, 4, and 6 and it's aliquot sum is 16.    A number whose aliquot sum equals its value is a PERFECT number (6 for example).  If we denote the aliquot sum by ASUM, then the condition for a perfect number is ASum(N)=N.  Numbers A and B with the property that ASum(A)=B and ASum(B)=A are called AMICABLE numbers. Longer cycles exist, these are sometimes called SOCIABLE numbers. For example ASum(A)=B, ASum(B)=C, ASum(C)=A would be a Sociable cycle of length 3. 

AliquotSums is a  program that will let you search for Perfect, Amicable and Sociable numbers, including one remarkable cycle 28 numbers in length.


Background & Techniques

The idea for this program came from a chapter in  Recreations in the Theory of Numbers   (Albert Beiler, Dover Publications).  In case you're wondering about that word ...

al·i·quot (àl¹î-kwòt´, -kwet) Mathematics. adjective  Of, relating to, or denoting an exact divisor or factor of a quantity, especially of an integer.   noun  An aliquot part. [Latin aliquot, some number : alius, some + quot, how many.]

 Perfect numbers are few and far between.  The first 3 are easily found,  the 4th can be found if you set the upper limit high enough, it's up around 3,500,000 as I recall.  Amicable pairs are fairly common but search times get long when we get up in the millions.

TIntEdit numeric edit components are used to collect some values (start and stop values, a maximum cycle  length to check and a maximum sum)  that control each run.  TIntEdit is available here.  You will need to install it before compiling  AliquotSums or change TIntEdits to TEdits and write your own code to check and convert edit text value to Int64 values.        

AliquotSums uses the Primes instance of the TPrimes class (both defined in the U_Primes unit) to factor each number to be tested.   One problem is that we need to find all factors and Primes returns only the prime factors.  Fortunately the mathematicians come through again with an equation to calculate the sum of all factors without enumerating them.  For each prime factor, p that  occurs e times the sum of factors it contributes is one less than  (pe+1-1)/(p-1).  So for example, if a number is divisible by 8 but not 16, the prime factor 2 occurs 3 times.  and  (23+1-1)/(2-1) =  15 =  1+2+4+8.   The   product of these expressions for all prime factors is the sum of all factors.  I played around with a few samples, and sure enough, it works,  but I'm not smart enough to explain why in simple terms.   So the function AliquotSum computes this for each trial number.  The new TIntList integer list class saves the results, and each sum becomes the input for the next calculation.  Each is checked against the first list entry checking to see if we are back where we started. If so a cycle has been found and we can display it and go on the next.

Lots of duplicates will show up, so each displayed value is saved in a second TIntList and aliquot cycles which begin with an already displayed value are skipped.   

 There are one other interesting  feature of the program:   The FormActivate method shows how to add margins to a TMemo using an EM_SetMargins message.  

The U_IntList unit containing the TIntList class is included in the source download.  You can  read more about and download a test project here.  

Running/Exploring the Program 

bulletDownload source
bulletDownload  executable

Suggestions for Further Explorations

Search on the term "Aliquot" or Aliquot sequence" and you find a number of dedicated pages.  There is a unproven conjecture  (I guess that's redundant, conjectures are unproven  by definition.)   that  every aliquot sequence either ends at 1 (when it reaches a prime number) or cycles.  They are mostly using C code and large integer components to factor large primes - hundreds of digits.  
There exist at least a few, and probably an infinite number, of aliquot triples, three numbers with the property that the aliquot sum of any two of them equals the third.  It would be an interesting problem  to modify AliquotSums to search for these triples.
I haven't found any aliquot sequences that cycle after 3 or 4 numbers.  I wonder if any exist?

    

 
  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2018, Gary Darby    All rights reserved.