Maths question re. factorials

If I have a database field with three characters - XXX - what’s the total possible permutations if I use an alphanumeric naming convention?

e.g. 001, 002, AB3, AB4

Is it as straight-forward as 36 x 36 x 36 = 46,656? :confused:

(Assume only uppercase letters).

36[sup]3[/sup]

Yep. It’s not a factorial, though, it’s a permutation.

Yes.

To elaborate a bit, you’re just writing numbers in base 36. If you exclude 000 as you did in your example then there are 36[sup]3[/sup]-1.

Thanks all :slight_smile:

If you wanted to use each character only once then there would be some factorials in the equation

36!/35!

36!/35! = 36, which isn’t correct. Without repeating characters, the total number of permutations would be:

36 × 35 × 34

OR

36!/(36 - 3)!

If I’m not mistaken, that should be 36!/33!.

ETA: See, that’s what happens when you open a thread in a tab and then read something else for 15 minutes.

The examples given in the OP suggest the addition unstated constraint that the three characters be in alphanumeric order.

It’s not a permutation, either, at least as defined by mathematicians.

I’m not sure if there’s a commonly accepted term for it, but it’s the result of a Cartesian product {0-9,A-Z} X {0-9,A-Z} X {0-9,A-Z}. And it’s related to the counting principle.

If each character was only used once, then, yes, it would be a mathematical permutation of 36 alphanumeric characters taken 3 at a time.

The formula for that would be:

P(n,r) = n! / (n-r)!

In this case, the 36! / (36 - 3)! = 36!/33! that was mentioned earlier.

It’s a permutation with repetitions.

In which case I think it is the sum of triangular numbers, which is n(n+1)(n+2)/6 . In this case, 8,436.

Slightly over my head at this point chaps, but it’s interesting stuff!

But to clarify… there’s no constraint in my particular case that the items be in alphanumeric order. So TA1 is valid, as is 93B etc.

Jeez, that’s what I get for posting before coffee.

I think it’s a “combinations” rather than a “permutations” problem. But yes, it’s with repetitions (more commonly called “replacement”): Combinations with replacement.

The logic of using the word “replacement” comes from the scenario where you are drawing various colored marbles from an urn (in elementary stat and probability, it’s always an “urn”), replacing each marble before the next draw, so that the same marble could be chosen again.

ETA: I partially take that back. It’s a permutations problem.
“With replacement” means the same letter or digit can appear more than once, e.g., ATA.
“Permutations” means the same letters in a different order count as a different result: ATZ is distinctly different from TZA or ZAT, and these would all count as separate possibilities.
“Combinations” means that the same letters in differing orders would all be counted as the same result: ATZ, TZA, ZAT would all count as just one result.