The Harshad or Niven numbers are positive integers ≥ 1 that are divisible by the sum of their digits.

For example,   42   is a Harshad number as   42   is divisible by   (4 + 2)   without remainder.

Assume that the series is defined as the numbers in increasing order.



Task

The task is to create a function/method/procedure to generate successive members of the Harshad sequence.

Use it to:

   list the first 20 members of the sequence,   and
   list the first Harshad number greater than 1000.


Show your output here.



Related task
   Increasing gaps between consecutive Niven numbers


See also
    OEIS: A005349


            NORMAL MODE IS INTEGER
 
            INTERNAL FUNCTION(A,B)
            ENTRY TO REM.
            FUNCTION RETURN A-A/B*B
            END OF FUNCTION 
 
            INTERNAL FUNCTION(I)
            ENTRY TO DSUM.
            SUM = 0
            REST = I
DIGIT       WHENEVER REST.NE.0
                SUM = SUM + REM.(REST,10)
                REST = REST/10
                TRANSFER TO DIGIT
            END OF CONDITIONAL
            FUNCTION RETURN SUM
            END OF FUNCTION
 
            INTERNAL FUNCTION(I)
            ENTRY TO NEXT.
LOOP        THROUGH LOOP, FOR NX=I+1, 1, REM.(NX,DSUM.(NX)).E.0
            FUNCTION RETURN NX
            END OF FUNCTION
 
            PRINT COMMENT $ FIRST 20 HARSHAD NUMBERS:$
            H = 0
            N = 0
HARSHD      WHENEVER N.LE.1000
                N = NEXT.(N)
                H = H + 1
                WHENEVER H.LE.20, PRINT FORMAT HSHD, H, N
                TRANSFER TO HARSHD
            END OF CONDITIONAL
 
            PRINT FORMAT THSND, N
 
            VECTOR VALUES HSHD = $8HHARSHAD(,I2,4H) = ,I2*$
            VECTOR VALUES THSND = 
          0     $34HFIRST HARSHAD NUMBER ABOVE 1000 = ,I4*$
 
            END OF PROGRAM 