Amicable pairs: Difference between revisions

Amicable pairs en BASIC256
(Add Draco)
(Amicable pairs en BASIC256)
Line 930:
17296 18416
</pre>
 
 
=={{header|BASIC256}}==
{{trans|FreeBASIC}}
<lang BASIC256>function SumProperDivisors(number)
if number < 2 then return 0
sum = 0
for i = 1 to number \ 2
if number mod i = 0 then sum += i
next i
return sum
end function
 
dim sum(20000)
for n = 1 to 19999
sum[n] = SumProperDivisors(n)
next n
 
print "The pairs of amicable numbers below 20,000 are :"
print
 
for n = 1 to 19998
f = sum[n]
if f <= n or f < 1 or f > 19999 then continue for
if f = sum[n] and n = sum[f] then
print rjust(string(n), 5); " and "; sum[n]
end if
next n
end</lang>
{{out}}
<pre>The pairs of amicable numbers below 20,000 are :
 
220 and 284
1184 and 1210
2620 and 2924
5020 and 5564
6232 and 6368
10744 and 10856
12285 and 14595
17296 and 18416</pre>
 
 
=={{header|BCPL}}==
2,170

edits