bubblenut's on the right track. Further progress can be made by noting that all of those entries will need to be added together; so you might as well add them as you go. Instead of "numbers with 1 digit, numbers with 2 digits, numbers with 3 digits..." count "numbers with up to 1 digit, numbers with up to 2 digits, numbers with up to 3 digits..." and see what proportion of each of those contains a '3'. This might allow a simpler general expression.

    bubblenut,

    in your statement, the i's can be factored out and reduced.

    ( (i10-1) + (i10-1 - i*10-2) ) / i

    since i exists in eahc member of the numerator, it can be factored out, and since it exists in the denominator the same amount of times as the numerator, it is gone.

    the 10-1 is actually 1/10, because it's a negative exponent.

    the second one would be (1/10)-(1/100), so there's a flaw.

    because the probability is how many times a member will appear within a set period
    AND
    since there is no requirement on a different member meeting a criterion
    AND
    because each part of the whole is using the same set
    THEN
    the probability would not change. it would be the probability of the number occuring in the set...

    which is 1/10

    trick quesiton.

    (edited to be easier to read)

      Originally posted by mattsinclair
      because the probability is how many times a member will appear within a set period
      AND
      since there is no requirement on a different member meeting a criterion
      AND
      because each part of the whole is using the same set
      THEN
      the probability would not change. it would be the probability of the number occuring in the set...

      which is 1/10

      But observe that even though only ten percent of natural numbers have a '3' as their final digit, that does not mean that the other ninety percent have no '3's at all. So the solution must be >1/10.

        For some reason I was thinking like it was a string variable... not an integer. In otherwords "303" would have 3 members, not three hundred and three.

        I'll have to rethink this on my way to the store...

          Something that just occurred to me that I thought I should mention as it makes the working easier for anyone who might not otherwise be aware of it ("natural number" only got its modern definition in 1986).

          0 is a natural number. So there are ten natural numbers with one-digit decimal numerals: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

          (And, to complete the definition of a natural number: "If n is a natural number, so is n plus one.")

            No?

            Okay.

            I'll build up towards a solution, but first let's start off with some numeric experiments. A wee PHP program gave me the following table:

            n   Number of n-digit #s   Proportion of occurrences of '3'
            1       10                      1/10
            2       90                     18/90
            3      900                    252/900
            4     9000                   3168/9000
            5    90000                  37512/90000
            6   900000                 427608/900000
            

            Those numbers are a bit messy; note, for example, that there are ten one-digit numerals (0,1,2,3,4,5,6,7,8,9), but only 90 two-digit numerals. This of course is because '0' is the only numeral with a leading zero digit.

            Besides, we'll still need to add them all together again later, when we try to consider all natural numbers at once.

            So what we'll do instead, is consider numerals that have at most n digits. Or, to put it another way, we'll consider the decimal representations of the first 10n natural numbers for successive n. Up to n=6 (i.e., 0..999999), the table becomes

            n   10^n      Proportion of occurrences of '3'
            1        10        1/10
            2       100       19/100
            3      1000      271/1000
            4     10000     3433/10000
            5    100000    40951/100000
            6   1000000   468559/1000000
            

            This can be worked out from the previous table of course because e.g., 271=252+18+1.

            But what does that achieve? What pattern is there to those numbers? Well, let's tinker with them a bit and see what we get.

                 1/10      = 0.1      = 1-0.9      = 1-9^1/10^1 = 1-(9/10)^1
                19/100     = 0.19     = 1-0.81     = 1-9^2/10^2 = 1-(9/10)^2
               271/1000    = 0.271    = 1-0.729    = 1-9^3/10^3 = 1-(9/10)^3
              3433/10000   = 0.3433   = 1-0.6561   = 1-9^4/10^4 = 1-(9/10)^4
             40951/100000  = 0.40951  = 1-0.59049  = 1-9^5/10^5 = 1-(9/10)^5
            468559/1000000 = 0.468559 = 1-0.531441 = 1-9^6/10^6 = 1-(9/10)^6
            

            But that exponent is just n all over again. We now have our general expression for the proportion of numerals up to n digits in length that contain a '3':

            1-(9/10)n.

            And there was much rejoicing.

            More to come (unless someone beats me to the punchline).

              originally posted by Weedpacket
              And there was much rejoicing.

              And what exactly do we do now, eat the minstrels? 😃

              I almost burned up a CPU on this one. As you've more/less shown, expressed as a percentage, the probability increases several % for each power of 10 with a decrease in the increase as n is increased ... a 19% chance out of 100, 27.1% in 1000, 34.39% in 10,000, 40.951% out of 100,000, 46.856% (rounded) in 1,000,000, 52.17% in 10,000,000 and after that it got boring sitting around waiting for the 100 million computation to finish, as I don't have a Cray, or even a Beowulf cluster. I guess if I'd been downloading a big file, I could have waited ... might have been interesting to see what would happen when PHP got up to 90% or more of CPU.....

              Based on this, I'd have to guess that for an infinitely large natural number nnn..., you're gonna have a repeating decimal nine, a la 99.99999...% chance....

              I'm pretty sure that that's what your regexp says, isn't it? 😉 Thanks for the enlightenment. Makes me wish I'd learned much more mathematics much earlier in life.

              Hmm, punchline[?]: Merve was almost right for numbers close to infinity; or, perhaps "Is there an odd perfect number?" 😃

                I'm going to make a stupid educated guess and say 2/19 is the probability. (I think I'm totally off-base though.)

                  Well I'm going to give another bit of reasoning (better than numeric experiments) before giving the answer; mainly 'cos I've already written it and I don't want it to go to waste.

                  It has to be admitted that a few numeric experiments do not a proof make, however. Who knows, the pattern could go wonky with n=7, or 9, or 10, or.... What would be nice is something a little more solid. A chain of reasoning that doesn't involve conducting numeric experiments might go something like this:

                  Consider the set of all natural numbers less than 10n. Put that another way, all n-digit decimal numerals where those less than 10(n-1) have been padded with leading zeros (oh, but you can do that, because it doesn't affect how many numerals do or don't have a '3' in them! If you don't like it you can just keep the shorter numerals around and say that, e.g, '57' does not have a '3' in the thousands position - which is true!). How many of these numerals contain a '3'?

                  Well, ten percent of them have a '3' in the units position. In other words, (1/10) of them.

                  Of the remaining ninety percent (i.e., those that don't have a '3' in the units position), ten percent have a '3' in the tens position. That is to say, ten percent of ninety percent, or (1/10)(9/10).

                  Of the remaining ninety percent of those, ten percent have a '3' in the hundreds position. That's (1/10)(9/10)(9/10) = (1/10)(9/10)2.

                  Etc...

                  ...of the remaining ninety percent of those, ten percent have a '3' in the - um - (n-1)illions position, (i.e., the "first" or leftmost position). That's (1/10)(9/10)(n-1).

                  Now let's add those all together.

                  (1/10) + (1/10)(9/10) + (1/10)(9/10)^2 + ... + (1/10)(9/10)^([i]n[/i]-1)
                  = (1/10)(1 + (9/10) + (9/10)^2 + ... + (9/10)^([i]n[/i]-1))
                  

                  Oh, this is just summing a geometric progression! Talk about in-your-sleep!

                           [i]n[/i]-1
                  = (1/10)(SUM (9/10)^[i]i[/i])
                           [i]i[/i]=0
                  
                  =(1/10)(1-(9/10)^[i]n[/i])/(1-9/10)
                  

                  And simplify that a bit. (It really could do with a bit of simplification!)

                  =(1/10)(1-(9/10)^[i]n[/i])/(1-9/10)
                  =(1/10)(1-(9/10)^[i]n[/i])/(10/10-9/10)
                  =(1/10)(1-(9/10)^[i]n[/i])/(1/10)
                  =1-(9/10)^[i]n[/i]
                  

                  Hurrraaaay.

                  If you want to be rigorous about that argument, it can be formulated in terms of induction on n.

                    If I knew I could pad everything with 0's, then I would've figured it out a long time ago! :mad:

                    Nah, I'm just kidding; I'm no mathematician, that's a nice puzzle Weed and you had me stumped. 🙂

                      Oh, go ahead: that's the general expression for n, but what is n? It's supposed to be the number of digits in a randomly-selected natural number, but how many is that, and what does it make the value of the expression?

                        And so I wrap up. dalecosp came closest it has to be said (no, no prizes except a sense of intellectual achievement).

                        The full and final answer to the puzzle is the same as the answer to the question "what happens to that expression as n approaches infinity? What value (if any) does it take?"

                        As n gets larger, (9/10)n is obviously going to get smaller. How much smaller? As small as we like: any number ε you might suggest as a limit to how tiny it can go can be beaten for tinyness by (9/10)n just by picking a big enough value for n. And we're allowed to pick n as big as we like because there'll always be natural numbers whose decimal representations have that many digits.

                        So no matter what how small a positive real number might be suggested for the value of (9/10)n as n approaches ∞ the fact is that the real value is smaller. Smaller than any positive number in other words. And there is only one number that is smaller than any positive number.

                        Zero.

                        As n approaches infinity, (9/10)n approaches zero, and hence 1-(9/10)n approaches 1. And that's the answer to the question I started the thread with.

                        What is the probability that a randomly-selected natural number has the digit '3' in its decimal representation?

                        Answer: 1.

                        Pick any natural number at random, and it is certain to contain a '3' in its decimal representation.

                          Weed you were close but still very far away.
                          The first digit of a number cannot be zero, otherwise
                          probability of 3, 03, 003, 0000000000000000003 will all be different even if those numbers are mathematically same.

                          assuming that 0 cannot come in the first place
                          we have the expression as

                          (1/9) + (1/9)(9/10) + (1/9)(9/10)^2 + ... + (1/9)(9/10)^([i]n[/i]-1)
                          = (1/9)(1 + (9/10) + (9/10)^2 + ... + (9/10)^([i]n[/i]-1))
                          

                          where n is the number of digits.

                          now use the GP.

                          for finite n it will be
                          probability will be (10/9)(1-(9/10)n)

                          for n=infinite
                          probablity will be (10/9)/(1-0) = 10/9 which is greater than 1, => sure shot.

                            probability :

                            maybe... maybe not... pass me another beer

                            Every problem can find its solution in pure evil denial.

                              Originally posted by jayant
                              Weed you were close but still very far away.
                              The first digit of a number cannot be zero, otherwise
                              probability of 3, 03, 003, 0000000000000000003 will all be different even if those numbers are mathematically same.

                              No, they're all the same, as I noted in the parenthetical remark. The number of n-digit numerals with leading zeros is for present purposes identical to the set of all n-digit or shorter numerals without leading zeros. Either way, the number three only gets counted once.

                              The fact that you get a probability that is greater than one just shows that you made a mistake somewhere.

                                Pick any natural number at random, and it is certain to contain a '3' in its decimal representation.

                                I dont quite understand the implication of the mathematics, though.

                                If we were indeed to select a natural number at random, quite obviously we may still pick a number that does not contain a '3' in its decimal representation, since such numbers exist.

                                But then is that because we (as in human beings doing the selection, or using a computer) cannot really select from the entire set of natural numbers?

                                  The probability is 1 ?!

                                  I doubt it... that's like saying that every natural number has the digit 3 in it. I think i'll check if the probability of picking a natural number WITHOUT the digit 3 is actually 0. 😛

                                    "This branch of mathematics [Probability] is the only one, I believe, in which good writers frequently get results which are entirely erroneous." ---Charles Pierce

                                    😉

                                      What I think Weed is saying is that the probability is so damn close to one that for all practical purposes, it is 1.

                                        Originally posted by Merve
                                        What I think Weed is saying is that the probability is so damn close to one that for all practical purposes, it is 1.

                                        No, I'm saying it is 1.

                                        Pick a natural number - any natural number - at random, and there will be a '3' in its decimal representation. You've got no chance of missing it; like trying to hit an infinitely small bulls-eye with an infinitely sharp dart, only harder. Or rolling a pair of dice forever and never getting snake eyes.

                                        Kind of goes to show just how unrepresentative the natural numbers we're familiar with are.

                                        And, abx_2112, the probability of picking a natural number without a '3' in its decimal representation is 0. It's the limit of (9/10)n as n tends towards ∞.

                                        The Frivolous Theorem of Arithmetic:
                                        Almost all natural numbers are very, very, very large.