ProSum Numbers are obtained when the product of an integer's digits divided by the sum of its digits is itself an integer. If the resultant integer can be used to produce yet another integer in the same way, a sequence is formed. It is terminated when a new term is less than 10. The first term must be at least 10, or an endless loop is formed.
Find the lowest starting term for a sequence of two ProSum Numbers, then do the same for three terms and four terms.
DECLARE FUNCTION sod# (x#)
DEFDBL A-Z
DIM r(10), found(10, 10)
CLS
FOR i = 10 TO 9999999
n = i
ct = 0
DO
ct2 = 0
flag$ = ""
s = sod(n)
IF n MOD s = 0 THEN
ct = ct + 1
r(ct) = n
IF n < 11 THEN EXIT DO
n = n / s
IF s = 1 THEN EXIT DO
ELSE
EXIT DO
END IF
LOOP
IF found(ct, 0) = 0 THEN
found(ct, 0) = i
PRINT i, ct
FOR j = 1 TO ct
found(ct, j) = r(j)
PRINT " "; r(j)
NEXT
PRINT flag$
END IF
NEXT i
'
FUNCTION sod (x)
ns$ = LTRIM$(STR$(x))
tot = 0
FOR i = 1 TO LEN(ns$)
tot = tot + VAL(MID$(ns$, i, 1))
NEXT
sod = tot
END FUNCTION
finds
10 1
10
11 0
12 2
12
4
108 3
108
12
4
1080 4
1080
120
40
10
19440 5
19440
1080
120
40
10
So the lowest with two is 12,4; the lowest with three is 108,12,4 and the lowest with four is 1080,120,40,10. In addition, the lowest with five is 19440,1080,120,40,10. All these repeat thereafter, including the 2-digit 10.
|
Posted by Charlie
on 2015-01-28 11:19:45 |