1

I am working on the following problem...

An early BASIC compiler recognized variable names according to the following rules: Numeric variable names had to begin with a letter and this letter could then be followed by another letter or a digit or by nothing at all. String variable names had to begin with the symbol $ followed by a letter, which could then be followed by another letter or a digit or by nothing at all. How many distinct variable names were recognized by this BASIC compiler?

So.. total number of distinct names = number of numerical variables names + number of string variable named.

Numeric variable names must begin with a letter and can be followed by another letter, a digit, or nothing. So I get 26*26 if it's a letter 26*10 if it's a number and 26 if it's nothing which totals 962 possibilities.

String variable names must begin with a $ symbol then a letter then another letter, digit, or nothing. So I get 1*26*26 for if the 3rd is a letter, 1*26*10 if it's a number, and 1*26 if it's nothing. That would also total 962 possibilities.

The Total would then be 962+962=1924

Now my question is does that make sense, or do the cases where the end is nothing not need the 0 because that is effecting the answer?

  • "Do the cases where the end is nothing not need the 0 because that is effecting[sic] the answer" Well, stop and think. How many ways can you have a letter followed by nothing. $26$ ways? Or $26\times 0=0$ ways? – JMoravitz Dec 06 '17 at 01:58
  • Well when you put it that way obviously 26. So if I get rid of the 0's and re do the adding the rest looks right? –  Dec 06 '17 at 02:02
  • Yes.${}{}{}{}{}$ – Parcly Taxel Dec 06 '17 at 03:02

0 Answers0