MathsReadCompetitive mathematics
Pattern recognition · integer answermedium12 min

Fibonacci words

Recursive Word Patterns

Define words S1=A, S2=AB, and for every n≥3, Sn is Sn−1 followed immediately by Sn−2. How many characters are in S12? You only need the length, not the word itself. As a check, S3=ABA has length 3. Submit one integer.

Learning goal: Abstract a recursive string construction to a recurrence for lengths.

Look for the underlying structure rather than guessing the next number. Submit only the final integer; you can open hints below as needed.

Check your answer without signing in. Sign in to save your progress.

Accepted format: a whole number such as 42 or 123456789. No commas, formulas, or source code.

Hints

Hint 1

Let L(n) be the number of characters in S(n).

Hint 2

Concatenation makes the lengths add: L(n)=L(n−1)+L(n−2).

Hint 3

Start from L(1)=1 and L(2)=2, then build lengths through L(12).

Common mistake to avoid

Constructing huge strings unnecessarily or beginning with the wrong two lengths.

How to approach this problem

Concatenating words adds their lengths, regardless of repeated characters. Track only those lengths through the recurrence.

Worked example with different values

With seed lengths 2 and 3, the next three lengths are 5,8,13; constructing the words is unnecessary.

Apply the same reasoning to the challenge. This example is a separate practice problem.

Learn the technique: Sequence patterns: differences, recurrences and interleaving

Report a question or explanation issue

Sequence patterns · Repeating remainders

Back to problems →