REM amicable numbers
DECLARE EXTERNAL FUNCTION f
FOR n=1 TO 10000
   LET  m=f(n)
   if n<m AND n=f(m) THEN PRINT n,m
NEXT n 
END
EXTERNAL FUNCTION f(n)
LET s=1
FOR i=2 TO SQR(n ) 
   IF MOD(n,i)=0 THEN
      IF i=n/i THEN LET s=s+i ELSE LET s=s+i+(n/i)
   END IF
NEXT i
LET f=s
END FUNCTION
