# Computing Number of Possibilities

I'm asking this question in the context of a program I'm trying to write, but the problem I'm having seemed to be more of a mathematical one. (Also, I'm not quite sure what tags should be applied to this question, so please feel free to edit them.)

I'm trying to figure out how to compute the number of possibilities in a given set of numbers, where certain number "bits" or "slots" can be binary, while others can be trinary.

First of all I know that I can do this: If I have say, two "bits". 00 And I know I can put two values into them: 1 or 0 The possible combinations are:

00, 01, 10, 11

Or four possibilities.

I can compute this beforehand by raising the number of spaces to the number of possibilities. (i.e. 2 to the 2nd (2^2)) If I had three "bits", it would be 3 to the 2nd (3^2) giving us nine possibilities. If I had four "bits" I could raise 4 to the second, and so on.

Now my question is this:

How do I compute a value where certain of the spaces (or "bits) are binary while others are trinary or even higher. For example:

0 0

Where one "bit" or slot can have a value of either 1 or 0
Slot 2 can be either 1 or 0 or 2

i.e.
00, 01, 02, 10, 11, 12 are all of the possibilities.

In what way would I be able to calculate the number of possibilities beforehand?

-
In "I can compute this..." you are backwards. If you have four bits, each of which can be in three states, there are $3^4$, not $4^3$ possibilities. –  Ross Millikan Mar 12 at 1:22

If you have $n$ binary bits and $m$ ternary bits then the number of possibilities to form $n+m$ digit sequences if $2^n3^m$. For example you listed $2\cdot3 = 6$ possibilities when you had $n=1$ binary digit and $m=1$ ternary digit.

-
So say I have four bits, and the first two are binary, the third ternary, the fourth has four possible entries. I would compute this by: (2^2)*(3)*(4) Giving me 48. Is that correct? –  alex0112 Apr 23 '14 at 18:46
@alex0112 Yes that's correct.This is the basic law of multiplicativity for outcomes of joint events in terms of the number of outcomes of the individual events. –  user2566092 Apr 23 '14 at 19:09

There is an error in the original question. If you had 3 bits storing binary data the number of possibilities is $2^3$ or $8$ possibilities, not $3^2$ or $9$.

If B = the number of binary bits you have and T = the number of ternary bit you have then

Number of possibilities $= 2^B 3^T$

Notice that is multiplication of the two exponential calculations, not an addition.

-