0

I need a simple equation where the following rules apply:

The answer must be the total amount of possible codes.
Codes are made up of m number of possible digits.
In each code every digit needs to be used at least once.
A code may have repeated digits.

I would like to use the following variable names

c is the number of codes
m is the number of possible digits
n is the length of the combination

for: n=3 m=3

$^mP_n$ works because it simplifies to 3! or 6

but in cases where n<m it would break because $^-Z!$ is impossible

I did try using Chat-GPT however it is insisting that the answer is $c = m^n - (m-1)^n$ which doesn't work for any inputs I give it. With that equation I tried $m = 3 = n$

$c = m^n - (m-1)^n$

$c = 3^3 - (3-1)^3$

$c = 27 - 2^3$

$c = 27 - 8$

$c = 19$

Any help would be greatly appreciated.

Thank you.

  • 4
    AI systems like ChatGPT don't understand math! They just know to BS and pretend like they know things. – Karl Apr 13 '23 at 04:25
  • Your right. That is why I asked stack exchange I spent hours on this and it's probably a simple answer I'm not getting. – Adea selon Apr 13 '23 at 04:28
  • Thank you for replying @Karl What is W? – Adea selon Apr 13 '23 at 04:29
  • If you read the answer where $W$ appears, it starts with "Let $W(c,n)$ denote the number of words of length $c$ from an alphabet of $n$ letters. Then $W(c,n)=n^c$." – Karl Apr 13 '23 at 04:31
  • Sorry I must have missed that thank you. I am not sure I understand the concept of Stirling numbers if not to bother, do you have any credible sources. Thank you – Adea selon Apr 13 '23 at 04:32
  • I suggest reading the Wikipedia article and posting another question if there's something specific you're having trouble understanding. – Karl Apr 13 '23 at 04:35
  • Stirling numbers are derived via Inclusion-Exclusion theory. See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula. ...see next comment – user2661923 Apr 13 '23 at 04:36
  • As a logistical walk through, suppose that $~m~$ = 3, with the characters $~{1,2,3}~$ representing the alphabet, and suppose that $~n = 7.~$ Per the second cited Inclusion Exclusion reference in my previous comment, let $~S~$ denote the set of all possible $~7~$ digit numbers, without any regard for whether an element from $~{1,2,3}~$ is used at least once. For $~k \in {1,2,3},~$ let $~S_k~$ denote the subset of $~S~$ where the constraint that element $~k~$ must be used at least once is violated. Then, the desired computation is $$|S| - |S_1 \cup S_2 \cup S_3|.$$ – user2661923 Apr 13 '23 at 04:40
  • Thank you @user2661923 could I ask if there is any way to put that into a programable calculator? – Adea selon Apr 13 '23 at 04:58
  • I advise against that. Instead, I advise using a computer program to do the heavy lifting. If you are inexperienced at programming, then I suggest letting Python be your first programming language. Also, when you do all of the calculations, it is important to work exclusively with integers, rather than floating point numbers, for such a problem. Programming languages generally have special facilities for constructing integers with (for example) more than 100 digits. – user2661923 Apr 13 '23 at 05:02

0 Answers0