Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,79 @@
|
|||
function raiseTo( bas as ulongint, power as ulongint ) as ulongint
|
||||
dim as ulongint result = 1, i
|
||||
for i = 1 to power
|
||||
result*=bas
|
||||
next i
|
||||
return result
|
||||
end function
|
||||
|
||||
function properDivisorSum( n as ulongint ) as ulongint
|
||||
dim as ulongint prod = 1, temp = n, i = 3, count = 0
|
||||
while n mod 2 = 0
|
||||
count += 1
|
||||
n /= 2
|
||||
wend
|
||||
if count<>0 then prod *= (raiseTo(2,count + 1) - 1)
|
||||
while i*i <= n
|
||||
count = 0
|
||||
while n mod i = 0
|
||||
count += 1
|
||||
n /= i
|
||||
wend
|
||||
if count = 1 then
|
||||
prod *= (i+1)
|
||||
elseif count > 1 then
|
||||
prod *= ((raiseTo(i,count + 1) - 1)/(i-1))
|
||||
end if
|
||||
i += 2
|
||||
wend
|
||||
if n>2 then prod *= (n+1)
|
||||
return prod - temp
|
||||
end function
|
||||
|
||||
sub printSeries( arr() as ulongint ptr, size as integer, ty as string)
|
||||
dim as integer i
|
||||
dim as string outstr = "Integer: "+str(arr(0))+", Type: "+ty+", Series: "
|
||||
for i=0 to size-2
|
||||
outstr = outstr + str(arr(i))+", "
|
||||
next i
|
||||
outstr = outstr + str(arr(i))
|
||||
print outstr
|
||||
end sub
|
||||
|
||||
sub aliquotClassifier(n as ulongint)
|
||||
dim as ulongint arr(0 to 15)
|
||||
dim as integer i, j
|
||||
dim as string ty = "Sociable"
|
||||
arr(0) = n
|
||||
for i = 1 to 15
|
||||
arr(i) = properDivisorSum(arr(i-1))
|
||||
if arr(i)=0 orelse arr(i)=n orelse (arr(i) = arr(i-1) and arr(i)<>n) then
|
||||
if arr(i) = 0 then
|
||||
ty = "Terminating"
|
||||
elseif arr(i) = n and i = 1 then
|
||||
ty = "Perfect"
|
||||
elseif arr(i) = n and i = 2 then
|
||||
ty = "Amicable"
|
||||
elseif arr(i) = arr(i-1) and arr(i)<>n then
|
||||
ty = "Aspiring"
|
||||
end if
|
||||
printSeries(arr(),i+1,ty)
|
||||
return
|
||||
end if
|
||||
for j = 1 to i-1
|
||||
if arr(j) = arr(i) then
|
||||
printSeries(arr(),i+1,"Cyclic")
|
||||
return
|
||||
end if
|
||||
next j
|
||||
next i
|
||||
printSeries(arr(),i+1,"Non-Terminating")
|
||||
end sub
|
||||
|
||||
dim as ulongint nums(0 to 22) = {_
|
||||
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 as ubyte = 0 to 22
|
||||
aliquotClassifier(nums(n))
|
||||
next n
|
||||
Loading…
Add table
Add a link
Reference in a new issue