For any given n, there are 8 choices for the first digit (any digit except 0 or 7) of members of Nw, and 9 choices for each succeeding digit: qw(n) = 8 * 9^(n-1).
Since the total number of n-digit numbers is 9 * 10^(n-1), q7(n) = 9 * 10^(n-1) - 8 * 9^(n-1).
Constructing a table:
10 for I=1 to 30
20 print I,9*10^(I-1)-8*9^(I-1);8*9^(I-1)
30 next
40 for I=42 to 100 step 58
50 print I,9*10^(I-1)-8*9^(I-1);8*9^(I-1)
60 next
gives us
n q7(n) qw(n)
1 1 8
2 18 72
3 252 648
4 3168 5832
5 37512 52488
6 427608 472392
7 4748472 4251528
8 51736248 38263752
9 555626232 344373768
10 5900636088 3099363912
11 62105724792 27894275208
12 648951523128 251048476872
13 6740563708152 2259436291848
14 69665073373368 20334926626632
15 716985660360312 183014339639688
16 7352870943242808 1647129056757192
17 75175838489185272 14824161510814728
18 766582546402667448 133417453597332552
19 7799242917624007032 1200757082375992968
20 79193186258616063288 10806813741383936712
21 802738676327544569592 97261323672455430408
22 8124648086947901126328 875351913052098873672
23 82121832782531110136952 7878167217468889863048
24 829096495042779991232568 70903504957220008767432
25 8361868455385019921093112 638131544614980078906888
26 84256816098465179289838008 5743183901534820710161992
27 848311344886186613608542072 51688655113813386391457928
28 8534802103975679522476878648 465197896024320477523121352
29 85813218935781115702291907832 4186781064218884297708092168
30 862318970422030041320627170488 37681029577969958679372829512
...
42 889357764282167093521242008865140402572728
10642235717832906478757991134859597427272
...
100 8999763898676554777982809972158190418109485125819863649336911488922898584452532175837338324711960888
236101323445222017190027841809581890514874180136350663088511077101415547467824162661675288039112
7-digit numbers are the first where there are more numbers with 7 than without.
|
Posted by Charlie
on 2013-08-09 12:53:08 |