Anonymous user
Amicable pairs: Difference between revisions
→{{header|S-BASIC}}: followed approach of 2nd PL/I-80 example (runs MUCH faster!)
imported>Arakov |
imported>KayproKid (→{{header|S-BASIC}}: followed approach of 2nd PL/I-80 example (runs MUCH faster!)) |
||
Line 6,033:
$constant search_limit = 20000
var a, b, count = integer▼
dim integer sumf(search_limit)
print "Searching up to"; search_limit; " for amicable pairs:"▼
rem - set up the table of proper divisor sums
sum = 1 ▼
for a = 1 to search_limit
next a
for a = 2 to search_limit
while (b > 0) and (b <= search_limit) do
begin
end
next a
rem - search for pairs using the table
▲var a, b, count = integer
▲print "Searching up to"; search_limit; " for amicable pairs:"
count = 0
for a = 2 to search_limit
b = sumf(a)
if (b > a) and (b < search_limit) then
if a = sumf(b) then
begin
Line 6,070 ⟶ 6,068:
end
{{out}}
<pre>
|