What are the possible values of a six digit positive integer N, where all digits of N are different, and 4*N has the same six digits as N?
Prove that there are no others.
The first digit can be only 1 or 2, which is what the following program checks; the other digits can be any value 0 to 9.
DECLARE SUB addOn (wh#)
DEFDBL A-Z
CLEAR , , 25000
DIM SHARED dig(6), used(9), num, ct
addOn 1
PRINT ct
SUB addOn (wh)
IF wh = 1 THEN st = 1: fin = 2: ELSE st = 0: fin = 9
FOR i = st TO fin
IF used(i) = 0 THEN
used(i) = 1
num = 10 * num + i
dig(wh) = i
IF wh = 6 THEN
quad = 4 * num
REDIM used2(9)
n$ = LTRIM$(STR$(quad))
IF LEN(n$) = 6 THEN
good = 1
FOR j = 1 TO 6
d = VAL(MID$(n$, j, 1))
IF used2(d) > 0 OR used(d) = 0 THEN good = 0: EXIT FOR
used2(d) = 1
NEXT
IF good THEN
PRINT num, quad: ct = ct + 1
IF ct MOD 40 = 0 THEN STOP: PRINT
END IF
END IF
ELSE
addOn wh + 1
END IF
num = num \ 10
used(i) = 0
END IF
NEXT
END SUB
finds 64 values of N
N 4*N
102564 410256
103845 415380
104769 419076
104895 419580
105264 421056
106254 425016
125406 501624
125604 502416
126054 504216
140256 561024
140526 562104
142857 571428
153846 615384
154896 619584
167802 671208
167820 671280
167832 671328
167982 671928
168027 672108
169728 678912
169782 679128
170268 681072
172968 691872
176034 704136
176049 704196
178302 713208
178320 713280
179802 719208
179820 719280
179832 719328
180267 721068
180327 721308
182703 730812
182973 731892
183027 732108
190476 761904
196728 786912
197280 789120
197283 789132
197328 789312
197604 790416
197802 791208
197820 791280
197832 791328
198027 792108
201678 806712
201783 807132
201798 807192
201978 807912
216780 867120
216783 867132
216798 867192
216978 867912
217830 871320
217980 871920
217983 871932
219780 879120
219783 879132
230769 923076
230895 923580
238095 952380
239508 958032
239580 958320
239658 958632
|
Posted by Charlie
on 2014-03-26 10:59:32 |