25 lines
390 B
Text
25 lines
390 B
Text
dim sums(20000)
|
|
|
|
sub sum_proper_divisors(n)
|
|
dim sum = 0
|
|
dim i
|
|
if n > 1 then
|
|
for i = 1 to (n \ 2)
|
|
if n %% i = 0 then
|
|
sum = sum + i
|
|
end if
|
|
next
|
|
end if
|
|
return sum
|
|
end sub
|
|
|
|
dim i, j
|
|
for i = 1 to 20000
|
|
sums(i) = sum_proper_divisors(i)
|
|
for j = i-1 to 2 by -1
|
|
if sums(i) = j and sums(j) = i then
|
|
print "Amicable pair:";sums(i);"-";sums(j)
|
|
exit for
|
|
end if
|
|
next
|
|
next
|