(In reply to
good for 11 thru 999 by Charlie)
There are too many lines to list all 999 series, but they all did work. These are based on:
DECLARE SUB try (n#, lv#)
DECLARE FUNCTION nozero$ (n#)
DEFDBL A-Z
OPEN "casting out zeros.txt" FOR OUTPUT AS #2
DIM SHARED hMult(15), hProd(15), hNozero$(15), didit
n0 = 1
FOR n0 = 11 TO 999
IF n0 = 0 THEN END
n = n0
didit = 0
IF INSTR(STR$(n), "0") = 0 THEN
PRINT n0
PRINT #2, n0
try n, 1
IF didit = 0 THEN PRINT "-----------": PRINT #2, "------------"
END IF
NEXT
FUNCTION nozero$ (n)
s$ = ""
ns$ = LTRIM$(STR$(n))
FOR i = 1 TO LEN(ns$)
IF MID$(ns$, i, 1) > "0" THEN s$ = s$ + MID$(ns$, i, 1)
NEXT
nozero$ = s$
END FUNCTION
SUB try (n, lv)
FOR mult = 2 TO 99
IF didit THEN EXIT SUB
prod = mult * n
nz$ = nozero$(prod)
IF INSTR(STR$(prod), "0") > 0 AND mult MOD 10 <> 0 THEN
good = 1
FOR i = 1 TO lv - 1
IF hNozero$(i) = nz$ THEN good = 0: EXIT FOR
NEXT
IF good THEN
hNozero$(lv) = nz$
hProd(lv) = prod
hMult(lv) = mult
IF LEN(nz$) < 2 THEN
FOR i = 1 TO lv
PRINT i, hMult(i), hProd(i), hNozero$(i)
PRINT #2, i, hMult(i), hProd(i), hNozero$(i)
NEXT
didit = 1
EXIT FOR
ELSE
IF lv < 6 THEN
try VAL(nz$), lv + 1
END IF
END IF
END IF
END IF
NEXT mult
END SUB
BTW, to complete the 2-digit numbers, for 99:
99
1 11 1089 189
2 9 1701 171
3 6 1026 126
4 4 504 54
5 2 108 18
6 5 90 9
|
Posted by Charlie
on 2013-07-26 13:09:00 |