It is a well known fact that if you permute the digits of a number the difference will be a multiple of 9.
Define the sequence D, where D(n) is the smallest positive value that can be increased by 9n through a permutation of its digits. No leading zeroes are allowed so the first term is D(1)=12 not 10
1) Find the next 14 terms of D.
2) Note D(8) is the greatest n with two digits. What is the greatest n with 3, 4, 5, ... digits?
3) There are some numbers a, b such that a≠b but D(a)=D(b). Prove there are infinitely many such pairs.
4) Sometimes D(n)>9n and sometimes D(n)<9n. Prove that both cases happen an infinity of times.
5) Are there any values of n such that D(n)=9n?
n 9*n D(n)
2 18 13
3 27 14
4 36 15
5 45 16
6 54 17
7 63 18
8 72 19
9 81 109
10 90 120
11 99 102
12 108 102
13 117 124
14 126 125
15 135 126
16 144 127
17 153 128
18 162 129
19 171 130
20 180 130
21 189 123
22 198 103
23 207 103
24 216 135
25 225 136
26 234 137
27 243 138
28 252 139
29 261 140
30 270 140
31 279 134
32 288 124
33 297 104
34 306 104
35 315 146
36 324 147
37 333 148
38 342 149
39 351 150
40 360 150
41 369 145
42 378 135
43 387 125
44 396 105
45 405 105
46 414 157
47 423 158
48 432 159
49 441 160
50 450 160
51 459 156
52 468 146
53 477 136
54 486 126
55 495 106
Note that n in the program is not the n above, and the output was sorted for presentation above:
DIM taken(200)
FOR n = 11 TO 99999
ns$ = LTRIM$(STR$(n))
FOR add = 18 TO 55 * 9 STEP 9
mult = add / 9
IF taken(mult) = 0 THEN
i = n + add
ist$ = LTRIM$(STR$(i))
IF LEN(ist$) = LEN(ns$) THEN
good = 1
FOR i = 1 TO LEN(ns$)
ix = INSTR(ist$, MID$(ns$, i, 1))
IF ix = 0 THEN good = 0: EXIT FOR
ist$ = LEFT$(ist$, ix - 1) + MID$(ist$, ix + 1)
NEXT
IF good THEN
PRINT USING "#######"; mult; add; n
taken(mult) = 1
ct = ct + 1
IF ct MOD 40 = 0 THEN DO: LOOP UNTIL INKEY$ > "": PRINT
END IF
END IF
END IF
NEXT add
NEXT n
Edited on September 17, 2010, 5:29 pm
|
Posted by Charlie
on 2010-09-17 17:28:18 |