a person starts writing all 4 digit numbers .how many times had he written the digit 2

To determine the number of times the digit 2 appears when writing all 4-digit numbers, we can analyze the pattern of the digits.

In a 4-digit number, each digit can take any value from 0 to 9. However, for simplicity, let's consider the units place.

For the units place, the digit 2 can appear once (as in 2000), four times (as in 2002, 2012, 2022, 2032), and so on, until it appears 10 times (as in 2112, 2122, 2132, ..., 2192). This pattern repeats every ten numbers. So, in every set of ten numbers, the digit 2 appears once in the units place.

Now, let's move on to the tens place. Similarly, in each set of 100 consecutive numbers (from 2000 to 2099, then from 2100 to 2199, and so on), the digit 2 appears ten times in the tens place (as in 2002, 2012, ..., 2092).

Likewise, in the hundreds place, the digit 2 appears ten times in every set of 1,000 consecutive numbers (from 2000 to 2999, then from 3000 to 3999, and so on), as in 2200, 2201, ..., 2299.

Finally, in the thousands place, we can observe that in every set of 10,000 consecutive numbers, the digit 2 appears 1,000 times (from 2000 to 2999, 12000 to 12999, and so on).

To summarize:
- In the units place, the digit 2 appears once every 10 numbers.
- In the tens place, it appears once every 100 numbers.
- In the hundreds place, it appears once every 1,000 numbers.
- In the thousands place, it appears once every 10,000 numbers.

Since we are considering all 4-digit numbers, we need to consider all the places (units, tens, hundreds, and thousands). Thus, we add up the number of times 2 appears in each place:

1/10 (units place) + 1/100 (tens place) + 1/1,000 (hundreds place) + 1/10,000 (thousands place)

Simplifying the expression, we get:

0.1 + 0.01 + 0.001 + 0.0001 = 0.1111...

Therefore, the digit 2 appears approximately 0.1111 times in each 4-digit number.

Note: Since we are dealing with a continuous decimal, it is not possible to have a fractional count of a digit in a single number. The approximation of 0.1111 is given to show the repeating pattern. In reality, you cannot have a fraction of a digit in a single number.