Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nigel Wade Newsgroups: comp.lang.java.programmer Subject: Re: Mathematics, Java, good enough Date: Tue, 17 May 2016 12:56:32 +0100 Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net K3cALIJB9xtU4NrNbcP2iQjSzk9hEgw5XOtzXUAnT7rXXODgBU Cancel-Lock: sha1:UM7eQoHdFVedn1ehZQcQdwYFm30= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:34315 On 17/05/16 11:49, Duncan Idaho wrote: > Hello again > > I have a question that involves mathematics. I agree that it's off topic but as I am writing in Java > I thought I'd give it a go (tenuous I know but it's the best I've got). > > I'm dredging up set theory from the furthest reaches of my memory. I'll probably get it wrong. > Homework? If only, that would mean I could have the last 50 years again ... perhaps not. %-) > > Anyway > > I have a set of characters S of cardinality C > example > if S = {a..z, 0..9, A..Z} then C = er, um ..,62. > > For any given result string X, X need not be a set. > > eg if L = 8 then > "abcdefgh", "AAAAAAAA", "AABBCCDD" are all valid values for X > > how many strings of length L are possible from S > > I don't even know what to call the question and I probably won't understand the answer but it will be fun trying. > The answer is pretty simple. 62^8. The reasoning is also pretty simple. The first character has 62 possibilities. The second character also has 62 possibilities, so the first 2 characters have 62*62 possibilities (62^2) The third character also has 62 possibilities, so the first 3 characters have 62*62*62 possibilities (62^3) In general, for L from S, the number of possibilities is S^L. If you are not convinced, then just remove the letters and work with the numbers. The first digit can be 0-9. The second digit can be 0-9, so the allowed values are 00-99. And so on. This ought to be quite familiar. For 8 digits the range of possibilities would be 00000000-99999999. I'm not sure of the specific name is, most likely combination of probabilities.