Two integers 



N


{\displaystyle N}

 and 



M


{\displaystyle M}

 are said to be amicable pairs if 



N
≠
M


{\displaystyle N\neq M}

 and the sum of the proper divisors of 



N


{\displaystyle N}

 (




s
u
m

(

p
r
o
p
D
i
v
s

(
N
)
)


{\displaystyle \mathrm {sum} (\mathrm {propDivs} (N))}

) 



=
M


{\displaystyle =M}

 as well as 




s
u
m

(

p
r
o
p
D
i
v
s

(
M
)
)
=
N


{\displaystyle \mathrm {sum} (\mathrm {propDivs} (M))=N}

.



Example

1184 and 1210 are an amicable pair, with proper divisors:

   1, 2, 4, 8, 16, 32, 37, 74, 148, 296, 592   and 
   1, 2, 5, 10, 11, 22, 55, 110, 121, 242, 605   respectively.


Task

Calculate and show here the Amicable pairs below 20,000; (there are eight).



Related tasks
 Proper divisors
 Abundant, deficient and perfect number classifications
 Aliquot sequence classifications and its amicable classification. 


 
#lang transd
 
MainModule : {
    _start: (lambda
        (with sum 0 d 0 f Filter( from: 1 to: 20000 apply: (lambda
                (= sum 1)
                (for i in Range(2 (to-Int (sqrt @it))) do 
                    (if (not (mod @it i)) 
                        (= d (/ @it i)) (+= sum i)
                        (if (neq d i) (+= sum d))))
                (ret sum)))
            (with v (to-vector f)
                (for i in v do
                    (if (and (< i (size v)) 
                             (eq (+ @idx 1) (get v (- i 1))) 
                             (< i (get v (- i 1))))
                        (textout (+ @idx 1) ", " i "\n")
                    )))))
}