Closed form for a sequence of a language variables We developed a new language based on some rules:

Hailey Newton

Hailey Newton

Answered question

2022-05-24

Closed form for a sequence of a language variables
We developed a new language based on some rules: The language limits all variable names to zero or more letters from the set {b, e, d} followed by zero or more digits from the set {0, 1, 2, 3}. In other words, the empty string, b, 12, bed100, and bedb2012 are all legal variable names. However, 1b and be2d are not valid variable names. There is exactly 1 legal variable name of length 0, namely the empty string. There are exactly 7 legal variable names of length 1: b, e, d, 0, 1, 2, and 3. There are exactly 37 legal variable names of length 2: bb, be, bd, b0, b1, b2, b3, eb, ee, ed, e0, e1, e2, e3, db, de, dd, d0, d1, d2, d3, 00, 01, 02, 03, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, and 33. Your task is to find a closed-form expression for the number of legal variable names of length n in the language.
I have tried finding the sequence first so that I can find the closed-form but I am stuck in the first part, can't even go further. Like, the difference between length 0,1,2 is 1,7,37. Every form I take, I can't find the difference d from it. Not only that, how am I supposed to find a closed-form for it?

Answer & Explanation

Kaiden Porter

Kaiden Porter

Beginner2022-05-25Added 10 answers

Step 1
A variable name of length n is made up of a prefix of length k made of letters, and a suffix of length n k made of digits.
The number of such prefixes is 3 k , and the number of such suffixes is 4 n k .
Step 2
Therefore, the number of variable names of length n is
k = 0 n 3 k 4 n k = 4 n k = 0 n ( 3 4 ) k
Then use the rule for the sum of a geometric series, to get
4 n ( 1 ( 3 4 ) n + 1 1 3 4 ) = 4 n + 1 3 n + 1

Do you have a similar question?

Recalculate according to your conditions!

New Questions in Discrete math

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?