Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,52 @@
|
|||
# Rosetta Code problem: http://rosettacode.org/wiki/Aliquot_sequence_classifications
|
||||
# by Jjuanhdez, 06/2022
|
||||
|
||||
global limite
|
||||
limite = 20000000
|
||||
|
||||
dim nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 28, 496, 220, 1184, 12496, 1264460, 790, 909, 562, 1064, 1488}
|
||||
|
||||
for n = 0 to nums[?]-1
|
||||
print "Number "; nums[n]; " : ";
|
||||
call PrintAliquotClassifier(nums[n])
|
||||
next n
|
||||
print
|
||||
print "Program normal end."
|
||||
end
|
||||
|
||||
function PDtotal (n)
|
||||
total = 0
|
||||
for y = 2 to n
|
||||
if (n mod y) = 0 then total += (n / y)
|
||||
next y
|
||||
return total
|
||||
end function
|
||||
|
||||
subroutine PrintAliquotClassifier (K)
|
||||
longit = 52: n = K: clase = 0: priorn = 0: inc = 0
|
||||
dim Aseq(longit)
|
||||
|
||||
for element = 2 to longit
|
||||
Aseq[element] = PDtotal(n)
|
||||
n = int(Aseq[element])
|
||||
print n; " ";
|
||||
begin case
|
||||
case n = 0
|
||||
print " Terminating": clase = 1: exit for
|
||||
case n = K and element = 2
|
||||
print " Perfect" : clase = 2: exit for
|
||||
case n = K and element = 3
|
||||
print " Amicable": clase = 3: exit for
|
||||
case n = K and element > 3
|
||||
print " Sociable": clase = 4: exit for
|
||||
case n <> K and Aseq[element - 1] = Aseq[element]
|
||||
print " Aspiring": clase = 5: exit for
|
||||
case n <> K and Aseq[element - 2] = n
|
||||
print " Cyclic": clase = 6: exit for
|
||||
end case
|
||||
|
||||
if n > priorn then priorn = n: inc += 1 else inc = 0: priorn = 0
|
||||
if inc = 11 or n > limite then exit for
|
||||
next element
|
||||
if clase = 0 then print " non-terminating"
|
||||
end subroutine
|
||||
Loading…
Add table
Add a link
Reference in a new issue