Smith numbers are numbers such that the sum of the decimal digits of the integers that make up that number is the same as the sum of the decimal digits of its prime factors excluding 1.

By definition, all primes are excluded as they (naturally) satisfy this condition!

Smith numbers are also known as   joke   numbers.



Example
Using the number 166

Find the prime factors of 166 which are: 2 x 83

Then, take those two prime factors and sum all their decimal digits: 2 + 8 + 3 which is 13

Then, take the decimal digits of 166 and add their decimal digits: 1 + 6 + 6 which is 13

Therefore, the number 166 is a Smith number.



Task
Write a program to find all Smith numbers below 10000.



See also
 from Wikipedia:   [Smith number].
 from MathWorld:   [Smith number]. 
 from OEIS A6753:   [OEIS sequence A6753].
 from OEIS A104170:   [Number of Smith numbers below 10^n]. 
 from The Prime pages:   [Smith numbers].


            NORMAL MODE IS INTEGER
            PRINT COMMENT$ SMITH NUMBERS$
 
          R GENERATE PRIMES UP TO 10,000 USING SIEVE METHOD
            BOOLEAN SIEVE
            DIMENSION SIEVE(10000)
            DIMENSION PRIMES(1500)
 
            THROUGH SET, FOR I=2, 1, I.G.10000
SET         SIEVE(I) = 1B
 
            THROUGH NXPRIM, FOR P=2, 1, P.G.100
            WHENEVER SIEVE(P)
                THROUGH MARK, FOR I=P*P, P, I.G.10000
MARK            SIEVE(I) = 0B
NXPRIM      END OF CONDITIONAL
 
            NPRIMS = 0
            THROUGH CNTPRM, FOR P=2, 1, P.G.10000
            WHENEVER SIEVE(P)
                PRIMES(NPRIMS) = P
                NPRIMS = NPRIMS + 1
CNTPRM      END OF CONDITIONAL
 
          R CHECK SMITH NUMBERS 
            THROUGH SMITH, FOR I=4, 1, I.GE.10000
            WHENEVER .NOT. SIEVE(I)
                K = I
                PFSUM = 0
                THROUGH FACSUM, FOR P=0, 1, P.GE.NPRIMS .OR. K.E.0 
                L = PRIMES(P)
FACDIV          WHENEVER K/L*L.E.K .AND. K.NE.0
                    PFSUM = PFSUM + DGTSUM.(L)
                    K = K/L
                    TRANSFER TO FACDIV
FACSUM          END OF CONDITIONAL
                WHENEVER PFSUM.E.DGTSUM.(I), PRINT FORMAT NUMFMT,I
SMITH       END OF CONDITIONAL
 
            VECTOR VALUES NUMFMT = $I5*$
 
          R GET SUM OF DIGITS OF N          
            INTERNAL FUNCTION(N)
            ENTRY TO DGTSUM.
            DSUM = 0
            DNUM = N
LOOP        WHENEVER DNUM.E.0, FUNCTION RETURN DSUM
            DSUM = DSUM + DNUM-DNUM/10*10
            DNUM = DNUM/10
            TRANSFER TO LOOP
            END OF FUNCTION
            END OF PROGRAM