Você está na página 1de 7

ALGEBRAIC PROCEDURE FOR COUNTING DIGITS

Edson E S Sampaio November 17, 2012

Denition of problems
Let a be a digit from 1 to 9, N and q be positive integers and the algebraic expression, Q(N|a) = q, mean: the amount of digits a used to write all integers from 1 to N equals q. First problem: Determine q from the values of a and N. Second problem: For every a, determine the minimum value of N such that q = N, except for the trivial solution Q(1|1) = 1. A variation of this second problem involves the relationship q = kN. In this case, k is a positive rational number. The two problems are related to cryptography and code breaking. They aim to count whole numbers and a trivial way to solve them is to seek their solutions only with the use of computer algorithms. An algebraic approach to these problems allows to minimize the numerical calculation, and consequently the computing time. Furthermore, it provides a thorough understanding of the problems in analyzing its fundamentals. Thus, it can facilitate research on derivations and extensions of this class of problems possibly of practical interest. For these reasons, we discuss them algebraically.

Development of the solution


Order of units
Within the order of the units and for a positive integer a0 , Q(a0 |a) =

0, if a > a0 1, if a a0 9.

(1)

CPGG/UFBA - IGEO, Campus Universitrio de Ondina, 40170-290 Salvador, Bahia, a BRASIL; 55-71-3283-8603; edson@cpgg.ufba.br.

Order of tens
Within the order of tens: Q(10|a) = 2, if a = 1 1, if a > 1; (2)

12, if a = 1 3, if a = 2 Q(20|a) = 2, if a > 2; 13, if a < 3 4, if a = 3 Q(30|a) = 3, if a > 3; 14, if a < 4 5, if a = 4 Q(40|a) = 4, if a > 4. For a positive integer a1 9, induction results in: 10 + a1 , if a < a1 a1 + 1, if a = a1 Q(10a1 |a) = a1 , if a > a1 . It is easy to see that for intermediate numbers between two tens, Q ((10a1 + a0 )|a) = Q(10a1 |a) + Q(a0 |a), if a = a1 Q(10a1 |a) + Q(a0 |a) + a0 , if a = a1 .

(3)

(4)

(5)

(6)

(7)

The results for the orders of the units and tens allow writing that: Q ((a + 1)|a) = 1 (8)

Order of hundreds
Within the hundreds: Q(100|a) = 21, if a = 1 20, if a > 1; (9)

140, if a = 1 41, if a = 2 Q(200|a) = 40, if a > 2; 160, if a < 3 61, if a = 3 Q(300|a) = 60, if a > 3;

(10)

(11)

180, if a < 4 81, if a = 4 Q(400|a) = 80, if a > 4. For a positive integer a2 9, induction results 100 + 20a2 , 20a2 + 1, Q(100a2 |a) = 20a2 , in: if a < a2 if a = a2 if a > a2 .

(12)

(13)

It is easy to see that for intermediate tens between two hundreds,


2 2

Q
n=1

10 an

|a

=
n=1

Q (10n an |a) +

0, if a = a2 10a1 , if a = a2 .

(14)

The equivalent expression for intermediate numbers that are intermediaries between two hundreds is: 0, 2 2 a0 , 10n an |a = Q (10n an |a)+ Q 10a1 + a0 , n=0 n=0 10a1 + 2a0 ,

between two tens

if a = a1 e a = a2 if a = a1 e a = a2 if a = a1 e a = a2 if a = a1 e a = a2 . (15) The results for the orders of the tens and hundreds allow writing that: Q (10(a + 1)|a) = 10 + (a + 1). (16)

Order of thousands
Within the thousands: 3 102 + 1, if a = 1 3 102 , if a > 1; 3 10 + 6 102 , if a = 1 3 6 102 + 1, if a = 2 Q(2 10 |a) = 6 102 , if a > 2; 3 10 + 9 102 , if a < 3 3 9 102 + 1, if a = 3 Q(3 10 |a) = 9 102 , if a > 3; 3 10 + 4 3 102 , if a < 4 3 4 3 102 + 1, if a = 4 Q(4 10 |a) = 4 3 102 , if a > 4. Q(103 |a) = For a positive integer a3 9, induction results in: 3 10 + 3 102 a3 , if a < a3 3 3 102 a3 + 1, if a = a3 Q(10 a3 |a) = 3 102 a3 , if a > a3 . 3 (17)

(18)

(19)

(20)

(21)

The results for the orders of hundreds and thousands allow writing that: Q 102 (a + 1)|a = 102 + 2 10(a + 1). (22)

Generalized solution
First problem
From the above results, an induction procedure for each order in sequence leads to the following generalizations for n a positive integer: Q ((10n 1)|a) = n 10n1 , n 10 + n 10n1 an , if a < an n n 10n1 an + 1, if a = an Q (10 an |a) = n 10n1 an , if a > an . (23)

(24)

According to Equation 24, the number of digits exceeds the value of N for n 10, except for n = 10 and a > an where the two are equal. With the help of Equations 7, 14 e 15, an inductive recurrence procedure allows to generalize Equation 24 for any integer.
n n n j1

Q
m=0

10 am

|a

=
m=0

Q (10 am |a) +
j=1

aj
m=0

10m am .

(25)

aj =

1, if a = aj 0, if a = aj .

(26)

Equation 25 constitutes the solution of the rst problem. By way of illustration, the calculation of Q(31 600 000|3) leads to the development of: Q(31 600 000|3) = Q ((3 107 ) + (1 106 ) + (6 105 ))|3 Q(3, 16 107 |3) = (7 106 3 + 1) + (6 105 1) + (105 + 5 104 6) +106 1 + 105 6 = 23 600 001. (27)

Second problem
As a consequence of the rst line of Equation 24, Q(10n (a + 1)|a) = 10n + n 10n1 (a + 1). (28)

In Equation 28, N = 10n (a + 1). Therefore, the condition Q(N |a) = N happens if 10 10n1 + n(a + 1)10n1 = 10(a + 1)10n1 , 10 + na + n = 10a + 10, 10 a n = . (29) a+1 The numbers resulting from the solution of Equation 29 are integers only for the digits 1, 4 and 9. For the remaining six digits, fractional values of n result. Fractional values of n have no meaning, because they generate real numbers for N. Table 1 list all the results obtained using Equations 28 and 29 with the a 1 2 3 4 5 6 7 8 9 n 5 6,666. . . 7,5 8 8,333. . . 8,571428. . . 8,75 8,888. . . 9 10n (a + 1) 200 000 13 924 766 126 491 106 500 000 000 1 292 660 814 2 609 315 604 4 498 730 601 6 968 373 144 10 000 000 000 Range of possible N values 200 000 3 000 000 - 30 000 000 40 000 000 - 400 000 000 500 000 000 600 000 000 - 6 000 000 000 700 000 000 - 7 000 000 000 800 000 000 - 8 000 000 000 900 000 000 - 9 000 000 000 10 000 000 000

Table 1: Values of n and N for each value of a based on Equations 28 and 29. The non integer part was subtracted from the values of 10n (a + 1). values of the third column subtracted of the non integer part. The condition of the actual values of N will be the subject of further analysis. Even for integer values of N, this development is not the exact solution to the second problem. The result produces values of N for which Q(N|a) = N, but they are not necessarily the searched minimum. For a = 9, the minimum value of N is actually 1010 . Incidentally, Equation 23 proves that we use ten billion times any a to write all integers from 1 to 9 999 999 999. A regressive search process allows to nd the minimum values of N, for 1 and 4. The minimum values of N is equal to 199 981 for a = 1 and equal to 499 999 984 for a = 4. By way of demonstration: Q(199 981|1) = Q (105 + 9 104 + 9 103 + 9 102 + 8 101 + 1)|1 = 5 104 + 1 + 104 + 4 103 9 + 103 + 3 102 9 +102 + 2 10 9 + 101 + 8 + 1 + 99981 = 199 981. 5 (30)

Variation of the second problem


Evidently, the solution of Q(N |a) = kN for N = 10n (a + 1) is: n= 10(ka + k 1) . a+1 (31)

As an example of the variation of the second problem, the computation of Q(N |a) = N/2, k = 1/2 also results in integer values of n and N only for the digits 1, 4 and 9. For the other six digits, the computation yields fractional values of n, equally meaningless. Table 2 lists the results of Q(N |a) = N/2 with the values of the third column subtracted of the non integer part. a 1 2 3 4 5 6 7 8 9 n 0 1,666. . . 2,5 3 3,333. . . 3,571428. . . 3,75 3,888. . . 4 10n (a + 1) 2 139 1 264 5 000 12 926 26 093 44987 69 683 100 000 Range of possible N values 2 30 - 300 400 - 4 000 5 000 6 000 - 60 000 7 000 - 70 000 8 000 - 80 000 9 000 - 90 000 100 000

Table 2: Values of n and N for each value of a based on the expression Q(n|a) = N/2. Non-integer values were subtracted from 10n (a + 1).

Analysis of the actual values of N


The fourth column of Tables 1 and 2 shows a range of integer values for each value of a and n, in which 10n (a + 1) is a real number. The range corresponds to substituting n by the integer values immediately smaller and immediately larger than n. Should they exist, the values of N satisfying Q(N |a) = N and Q(N |a) = N/ 2 must be within those ranges. One way to perform this search is by half dividing the range successively. For a = 2, we started with N = 165 in Table 2, whose sequence of values is: 1. Q(165|2) = 37 < 165/2; 2. Q(233|2) = 88 < 233/2; 3. Q(266|2) = 124 < 266/2; 4. Q(283|2) = 143 > 283/2; 6

5. Q(282|2) = 142 > 282/2; 6. Q(281|2) = 140 < 281/2. Although we have abbreviated the process between the fourth and the fth steps, there is not a solution of N, satisfying the problem exactly. The closest value is 281. This situation must be repeated for every example where 10n (a+1) is a real number. With more or less work, one can calculate the nearest N satisfying a condition of minimum value for |Q(N |a) N k|, provided kN is an integer.

Final remarks
Arithmetics is the science of integers and the essential foundation of mathematics is the process of counting numbers. This development shows that this process is not as simple as one thinks. In fact, there are a number of subclass questions to answer within this topic, which require an enhancement of the analysis developed here. We illustrate this with two examples. Is there a value of N = 10 for which Q(N |1) = 2 Q(N |2)? When a procedure produces a non-integer value of N does it mean that there is no exact solution? May this analysis stimulate the search for new questions and their solutions within this topic and may it transcend beyond a great mental exercise. Suggestions, criticisms and, above all, solutions are welcome.

Você também pode gostar