Given an integer , generate the first terms of the Aronson’s sequence.
Aronson’s sequence is an infinite sequence of integers obtained from the index of T (or t) in the sentence:
“T is the first, fourth, eleventh, sixteenth, … letter in this sentence.”
- The first occurrence of T in the sentence is at index 1 (1-based indexing) and the number mentioned first is first i.e. 1
- Similarly, the second occurrence of t in the sentence is at index 4 and the number mentioned second is fourth i.e. 4
- Similarly, the third occurrence of t in the sentence is at index 11 and the number mentioned third is eleventh i.e. 11
- Likewise, The series continues as 1, 4, 11, 16, …
Input: n = 3
Output: 1, 4, 11
Input: n = 6
Output: 1, 4, 11, 16, 24, 29
Approach: A simple idea is to store the string “T is the” to get the first two terms of the sequence. For each of these terms, convert it to words in the ordinal form and append to the string and calculate the value of the next higher terms. Repeat this process for each of the subsequent higher terms generated for n-2 times to generate the first n terms of the Aronson’s sequence.
For converting a number to words refer here.
Below is the implementation of the above approach:
1, 4, 11, 16, 24, 29,
- Look-and-Say Sequence
- Sum of the sequence 2, 22, 222, .........
- k-th number in the Odd-Even sequence
- Sylvester's sequence
- Golomb sequence
- Gould's Sequence
- Connell Sequence
- Juggler Sequence
- Padovan Sequence
- Aliquot Sequence
- Farey Sequence
- Recaman's sequence
- Increasing sequence with given GCD
- Smarandache-Wellin Sequence
- Moser-de Bruijn Sequence
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.