N is a positive base ten integer having at least 2-digits but at most 4-digits, which is obtained by multiplying the sum of its digits with the product of its digits. It is known that N cannot contain any leading zero.
Determine all possible value(s) of N.
(In reply to
Solution & thoughts by Jer)
DEFDBL A-Z
FOR n = 10 TO 999999
s$ = LTRIM$(STR$(n))
sum = 0: prod = 1
FOR i = 1 TO LEN(s$)
d = VAL(MID$(s$, i, 1))
sum = sum + d: prod = prod * d
NEXT
IF sum * prod = n THEN
PRINT n, sum; prod
END IF
NEXT
finds only the same
135 9 15
144 9 16
as Jer.
|
Posted by Charlie
on 2010-06-21 14:22:24 |