# Thread: Urgent help regarding sequence required

1. ## Urgent help regarding sequence required

Given the first value, generate the next seven terms of the sequences like 1, 11, 21, 1211,
111221, 312211, 13112221, 1113213211.

I know how to generate a particular term but I am unable to do this

2. Seems familiar....
Building a Logic! - C++ Forum

3. I think I recognise that pattern from a TED-ed Video that I saw a long time ago.... I can't find the actual video right now but I this is a similar copy of the video by someone else that popped up first as per what I searched.

You've already figured out the logic for finding the next term if you solve manually but coding the same thing in a loop is quite difficult. Try counting the longest sequence of same numbers together and add the count with the current sequence number being counted to a string.

Ex: 11122

Count longest string of same numbers together...
3 1's
Continue parsing the string to find the next longest string of same numbers...
2 2's
.
.
.
(for different kinds of inputs)

There is someone who devised a mathematical solution to determine the N'th term of the sequence but I cannot remember/find the link to where I saw a more efficient solution compared to what I had made as my solution literally parsed through 7 of the previous string of numbers to find the 8th number.

4. A code would do please, thanks.

5. Originally Posted by Euno
A code would do please, thanks.

I don't think "a code" (LMAO) is necessary since code (in lots of languages, including C++) for generating and printing this sequence is available all over the place and a simple google search away.

Edit: If you cannot use google to find the solution or write the solution yourself (both options are so trivial that a 5-year-old could do it), perhaps you should give up on programming. Just a thought. All your code are belong to us.

6. If you insist on a solution without trying first (i.e. provide us a code where we can see what you've tried), then I agree to what @Hodor has to say....

Here you go:

Look-and-Say Sequence - GeeksforGeeks

I can't find the more efficient solution that I mentioned in my #3 post though.... don't know what I'd googled the last time I ever saw the solution