45 lines
1.3 KiB
Plaintext
45 lines
1.3 KiB
Plaintext
print "ROSETTA CODE - Aliquot sequence classifications"
|
|
[Start]
|
|
input "Enter an integer: "; K
|
|
K=abs(int(K)): if K=0 then goto [Quit]
|
|
call PrintAS K
|
|
goto [Start]
|
|
|
|
[Quit]
|
|
print "Program complete."
|
|
end
|
|
|
|
sub PrintAS K
|
|
Length=52
|
|
dim Aseq(Length)
|
|
n=K: class=0
|
|
for element=2 to Length
|
|
Aseq(element)=PDtotal(n)
|
|
print Aseq(element); " ";
|
|
select case
|
|
case Aseq(element)=0
|
|
print " terminating": class=1: exit for
|
|
case Aseq(element)=K and element=2
|
|
print " perfect": class=2: exit for
|
|
case Aseq(element)=K and element=3
|
|
print " amicable": class=3: exit for
|
|
case Aseq(element)=K and element>3
|
|
print " sociable": class=4: exit for
|
|
case Aseq(element)<>K and Aseq(element-1)=Aseq(element)
|
|
print " aspiring": class=5: exit for
|
|
case Aseq(element)<>K and Aseq(element-2)= Aseq(element)
|
|
print " cyclic": class=6: exit for
|
|
end select
|
|
n=Aseq(element)
|
|
if n>priorn then priorn=n: inc=inc+1 else inc=0: priorn=0
|
|
if inc=11 or n>30000000 then exit for
|
|
next element
|
|
if class=0 then print " non-terminating"
|
|
end sub
|
|
|
|
function PDtotal(n)
|
|
for y=2 to n
|
|
if (n mod y)=0 then PDtotal=PDtotal+(n/y)
|
|
next
|
|
end function
|