# What’s the next element of the sequence?

Recently I have been applying for the summer internships and one of the recruitment processes has really surprised me. I have submitted an application, I have been asked to take an online aptitude test, finally I have been invited for an interview and a set of tests in company’s office. Everything is fine so far, but things started to change on the day I visited the office – when I was given one of the tests. The whole test was about guessing what is the next element in the sequence!

Why I do not like it? Because if marked automatically, such tests check if you think as most of people – there is no place for creativity, forget about “thinking outside-of-the-box” – if you do not think about exactly the same solution as the question’s creator did, you are probably considered stupid. I would like to notice that everything is fine if markers discuss with the test participant all answers they want to mark as incorrect.

### Examples

3, 6, 9, 12, 15. What is next?

18 – because we can see that the difference between each two consecutive elements is three.

But what if I say 19? You have created a formula that works for the given 5 elements and answered what the function would return as sixth element. But what if I have found different function that would give 19?

1, 2, 4. What is next?

8 – because each element is twice the previous element.

Or maybe 7 because the difference between each two consecutive elements is increasing by one with each element, i.e. f(n+1) – f(n) = f(n) – f(n-1) + 1.

So if I – a question’s creator – had 8 in mind, but you have answered 7, does it make you stupid? No, of course not – you just think in a different way than I do, but your reasoning is fully correct and you should be awarded full marks. Some may say that such short sequences do not appear in the attitude tests, that it is just too short to unequivocally decide what the formula should be. This is true. This is also true if you are given more elements, any finite number of elements of the sequence. Let’s do a more complex example.

1, 2, 4, 8, 16. What are the next three elements?

32, 64, 128 – because f(n) = 2 ^ n.

31, 57, 99 – these are the maximum numbers of pieces into which we can divide a circle by connecting n points on circle’s perimeter to each other (polygon + all diagonals). This problem is known as Moser’s circle problem and is described by the following function: 0, 1, 2, 3, 4, 5, 6. What are the next three elements?

-23, π, √3. But if you say 7, 8, 9  you are right too. So how to work it out? Let f(n) be a function that we are looking for, then:

f(0) = 0
f(1) = 1
f(2) = 2
f(3) = 3
f(4) = 4
f(5) = 5
f(6) = 6
f(7) = -23
f(8) = π
f(9) = √3

Let f(n) be a polynomial of degree one less than the number of elements we have, i.e. 9. So:

f(n) = a·n^9 + b·n^8 + c·n^7 + d·n^6 + e·n^5 + f·n^4 + g·n^3 + h·n^2 + i·n + j

By substituting it with the values above we get:

j = 0
a + b + c + d + e + f + g + h + i + j = 1
512a + 256b + 128c + 64d + 32e + 16f + 8g + 4h + 2i + j = 2
and so on.

This is a set of 10 equations, with 10 variables (all to the power of 1), which is easy to solve and gives exactly one solution.

### Conclusion

No matter how many first elements of the sequence you are given, there is no unique answer what is the next element. As long as you can provide valid explanation of your answer (by e.g. providing the proper function), your answer is fully correct. This implies that if potential employer marks your answers without discussing them with you, they risk a loss of a potential employee who think “beyond the box” and who cannot be fitted to common templates. You should also think whether you really want to work for the company that penalises you for your creativity before you have even joined them. ## About Jaroslaw Pawlak

I have done MSci in Computer Science at King’s College London and currently work as Software Engineer specialising in Java. I spend most of my time in front of computer improving my programming (and other) skills or just relaxing with a good game. I also train some sports but at the moment I am not a member of any club. I love cycling and volleyball, but I have also played a lot of football, tennis and trained martial arts.