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. 


            NORMAL MODE IS INTEGER
            DIMENSION DIVS(20000)
            PRINT COMMENT $ AMICABLE PAIRS$
 
          R CALCULATE SUM OF DIVISORS OF N
            INTERNAL FUNCTION(N)
            ENTRY TO DIVSUM.
            DS = 0
            THROUGH SUMMAT, FOR DIVC=1, 1, DIVC.GE.N
SUMMAT      WHENEVER N/DIVC*DIVC.E.N, DS = DS+DIVC
            FUNCTION RETURN DS
            END OF FUNCTION
 
          R CALCULATE SUM OF DIVISORS FOR ALL NUMBERS 1..20000
            THROUGH MEMO, FOR I=1, 1, I.GE.20000
MEMO        DIVS(I) = DIVSUM.(I)
 
          R FIND ALL MATCHING PAIRS
            THROUGH CHECK, FOR I=1, 1, I.GE.20000
            THROUGH CHECK, FOR J=1, 1, J.GE.I
CHECK       WHENEVER DIVS(I).E.J .AND. DIVS(J).E.I, 
          0     PRINT FORMAT AMI,I,J
 
            VECTOR VALUES AMI = $I6,I6*$
            END OF PROGRAM