How Many Unique Character String Can Be Made From 62 Characters?

14.5k Views Asked by At

I'm working on a programming algorithm and need a little math help. I'm in 10th grade and I think the question I'm asking is actually a permutation and combination logic question. Okay, so I've 62 characters as follows:

0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

I want to know how many unique characters can be made from this? For example, for length 1 character, there could be 62 unique characters. Length 2 character, there could be 00,01,02,03....AA,AB,AC...FA,FB,FC,FD...ZA,ZB,ZC...0A,0B,0C...,etc.

I hope you are getting me what I'm trying to say. And the maximum length of the string should be 7 characters.

So, in total, how many unique random strings can be generated from these 62 characters!?

1

There are 1 best solutions below

3
On BEST ANSWER

Using $n$ unique characters, there are exactly $n^k$ strings of length $k$.

Think of it this way:

You have $n$ choices for the first character, $n$ for the second one... $n$ for the $k$-th one.

So the amount of options is

$$\underbrace{n·n·n\ldots n}_{k\text{ times}} = n^k$$

If you want to know the amount of strings with $n$ unique characters with length up to $k$ then you need to add:

$$n^1 + n^2 + n^3 + ... + n^k = \frac{n^{k+1}-n}{n-1}$$