Actually, the digits are not digits, are letters, but for the purposes of my application, all computations are done numerically, and not in string or char data types, for obvious efficiency.

Kind regards,

Then factorials just don't cut it.

If you can use any letter any number of times then using your example, if you have 4 different letters that you can repeatedly use to use to compose a 4 letter "word" (sequence of letters), then there are different words you can put together.

n different symbols that you can repeat can form diferent sequences of length k.
on every 'place' in the sequence of length k, you can always choose any of n available 'symbols'.

You know that with repeated charaters that the answer given is wrong, it assumes they are all distinguishable.

Good point, thanks. For the purpose of my word anagram application, I sure can't tell "alma" is distinguishable from "alma". They are the same, so I shouldn't count them twice as if different, like the factorial n! does.

you can use the multinomial coefficient

Thanks. I better implement that function in code, instead of factorial.