Find six strictly increasing terms - consisting entirely of positive integers - in arithmetic sequence that use precisely three different digits.
*** The highest term is less than 1000.
Initial number limited to 2000; increment limited to 4000, so this is an expansion of what's asked for.
1 6 11 16 21 26
2 7 12 17 22 27
11 61 111 161 211 261
12 62 112 162 212 262
16 66 116 166 216 266
21 71 121 171 221 271
22 72 122 172 222 272
27 77 127 177 227 277
111 611 1111 1611 2111 2611
112 612 1112 1612 2112 2612
116 616 1116 1616 2116 2616
121 621 1121 1621 2121 2621
122 622 1122 1622 2122 2622
126 626 1126 1626 2126 2626
161 661 1161 1661 2161 2661
162 662 1162 1662 2162 2662
166 666 1166 1666 2166 2666
211 711 1211 1711 2211 2711
212 712 1212 1712 2212 2712
217 717 1217 1717 2217 2717
221 721 1221 1721 2221 2721
222 722 1222 1722 2222 2722
227 727 1227 1727 2227 2727
271 771 1271 1771 2271 2771
272 772 1272 1772 2272 2772
277 777 1277 1777 2277 2777
from
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
For t1 = 1 To 2000
For incr = 1 To 4000
ReDim used(9): diffct = 0
good = 1
For i = 0 To 5
t = t1 + i * incr
ts$ = LTrim(Str(t))
For j = 1 To Len(ts$)
v = Val(Mid(ts$, j, 1))
If used(v) = 0 Then diffct = diffct + 1: If diffct > 3 Then good = 0: Exit For
used(v) = used(v) + 1
Next
If good = 0 Then Exit For
Next
If good Then Text1.Text = Text1.Text & Str(t1) & Str(t1 + incr) & Str(t1 + 2 * incr) & Str(t1 + 3 * incr) & Str(t1 + 4 * incr) & Str(t1 + 5 * incr) & crlf
DoEvents
Next
Next
Text1.Text = Text1.Text & "done"
End Sub
Edited on June 26, 2014, 3:30 pm
|
Posted by Charlie
on 2014-06-26 15:25:55 |