function aliquot(atom n) sequence s = {n} integer k if n=0 then return {"terminating",{0}} end if while length(s)<16 and n<140737488355328 do n = sum(factors(n,-1)) k = find(n,s) if k then if k=1 then if length(s)=1 then return {"perfect",s} elsif length(s)=2 then return {"amicable",s} end if return {"sociable",s} elsif k=length(s) then return {"aspiring",s} end if return {"cyclic",append(s,n)} elsif n=0 then return {"terminating",s} end if s = append(s,n) end while return {"non-terminating",s} end function function flat_d(sequence s) for i=1 to length(s) do s[i] = sprintf("%d",s[i]) end for return join(s,",") end function constant n = tagset(12)&{28, 496, 220, 1184, 12496, 1264460, 790, 909, 562, 1064, 1488, 15355717786080} sequence class, dseq for i=1 to length(n) do {class, dseq} = aliquot(n[i]) printf(1,"%14d => %15s, {%s}\n",{n[i],class,flat_d(dseq)}) end for