! amicable numbers up to 10000
DECLARE EXTERNAL FUNCTION f
LET t0=TIME
FOR n=1 TO 10000
   LET  m=f(n)
   if n<m AND n=f(m) THEN PRINT n,m
NEXT n 
PRINT time-t0; "seconds"
END
EXTERNAL FUNCTION f(n)
! the sum of all divisors except its own
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



