' Bench2.ibas
{CREATORID "LDB2"}
{VERSION "1.1"}

BEGIN
FOR B=1 TO 2
   GOSUB _PerfectNum
NEXT
WAIT
END

_PerfectNum:
   T=TICKS
   P=0 : C=B*500
   FOR N=2 TO C
      M=N\2 : S=1
      FOR D=2 TO M
         IF B=1 LET Y=N/D : X=N\D : IF Y=X LET S=S+D
         IF B=2 LET Y=N MOD D : IF Y=0 LET S=S+D
      NEXT
      IF S=N LET P=P+1
   NEXT
   R=TICKS-T/TICKSPERSEC
   IF P<>3 LET R=0
   PRINT R USING 2;
   PRINT " Secs"
RETURN