aliquot, version 1.0, 2026-10-31
Rolf Puetter

Let n be a positive integer. Define s(n) to be the sum of the proper divisors (not n itself) of n.
For example s(10) = 1+2+5 = 8, s(1) = 0, s(6) = 6
Add the definition s(0) = 0.
The aliquot sequence of n is then defined by
s0 = n, s1 = s(n), s2 = s(s(n)), s3 = s(s(s(n))),...

The sequence may converge, become periodic (e.g. s(220) = 284, s(284) = 220), or diverge.

A number n with s(n) = n is called perfect (e.g. 6, 28).
A pair of numbers n, m with s(n) = m, s(m) = n is called amicable (period of length 2)
Numbers forming a longer period (starting e.g with 1305184) a called sociable.

Copy aliquot.tns to your nspire, open it and enter aliquot(x) (x a positive integer) on the
calculator page. The program then displays s(x) and this number is preset in the input prompt.
You just need to press Enter to get the next member in the aliquot sequence of x. Enter 0 or press
Cancel to end the program.
So start with any number and try to find more perfect, amicable or sociable numbers.

The program computes s(n) by taking factor(n) and parsing the result string. So it's somewhat longer
than just finding the divisors by trying to divide by 2,3,...[n/2] without remainder, but I hope faster.


 