These define three classifications of positive integers based on their   proper divisors.

Let   P(n)   be the sum of the proper divisors of   n   where the proper divisors are all positive divisors of   n   other than   n   itself.

   if    P(n) <  n    then  n  is classed as  deficient  (OEIS A005100).
   if    P(n) == n    then  n  is classed as  perfect    (OEIS A000396).
   if    P(n) >  n    then  n  is classed as  abundant   (OEIS A005101).



Example

6   has proper divisors of   1,   2,   and   3.

1 + 2 + 3 = 6,   so   6   is classed as a perfect number.



Task

Calculate how many of the integers   1   to   20,000   (inclusive) are in each of the three classes.

Show the results here.



Related tasks

   Aliquot sequence classifications.   (The whole series from which this task is a subset.)
   Proper divisors
   Amicable pairs


PROC FillSumOfDivisors(CARD ARRAY pds CARD size,maxNum,offset)
  CARD i,j
 
  FOR i=0 TO size-1
  DO
    pds(i)=1
  OD
  FOR i=2 TO maxNum DO
    FOR j=i+i TO maxNum STEP i
    DO
      IF j>=offset THEN
        pds(j-offset)==+i
      FI
    OD
  OD
RETURN
 
PROC Main()
  DEFINE MAXNUM="20000"
  DEFINE HALFNUM="10000"
  CARD ARRAY pds(HALFNUM+1)
  CARD def,perf,abud,i,sum,offset
  BYTE CRSINH=$02F0 ;Controls visibility of cursor
 
  CRSINH=1 ;hide cursor
  Put(125) PutE() ;clear the screen
  PrintE("Please wait...")
 
  def=1 perf=0 abud=0
  FillSumOfDivisors(pds,HALFNUM+1,HALFNUM,0)
  FOR i=2 TO HALFNUM
  DO
    sum=pds(i)
    IF sum<i THEN def==+1
    ELSEIF sum=i THEN perf==+1
    ELSE abud==+1 FI
  OD
 
  offset=HALFNUM
  FillSumOfDivisors(pds,HALFNUM+1,MAXNUM,offset)
  FOR i=HALFNUM+1 TO MAXNUM
  DO
    sum=pds(i-offset)
    IF sum<i THEN def==+1
    ELSEIF sum=i THEN perf==+1
    ELSE abud==+1 FI
  OD
 
  PrintF("  Numbers: %I%E",MAXNUM)
  PrintF("Deficient: %I%E",def)
  PrintF("  Perfect: %I%E",perf)
  PrintF("  Abudant: %I%E",abud)
RETURN