ThoughtWorks Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
5
of 5 vote

2,2,4,11....
difference between the n and n-1...follows the sequence 0,2,7...
now 0 can be made as 0*0=0,similar 2 can be made as 1*1+1=2 and 7 can be made as 2*2+2+1=7,following the sequence we get the next difference as 15(3*3+3+2+1)..therefore the next number is 26 in the series.

- Abhay July 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nice one

- siprit July 31, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

good one

- cnrani March 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

good one

- cnrani March 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nice way to explain..

- matty March 12, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

2 5 8(should be)
0 2 7 X
2 2 4 11 Y

so x should be 15
So y = 11+15 = 26

- vin October 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
2
of 4 votes

series is
2 2 4 11
difference series is
0 2 7
Again take difference series
2 5
Again
3

so we have 3 now.

add 3 to its above series => 2 5 8
now add this 8 to last term of its above series => 0 2 7 15

Now add this 15 to last term of its above series =>2 2 4 11 26

This is what I mean :)

- vin October 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice explain

- leokuang4 November 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice 1

- Abhilash June 02, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

2* 0 + 1 = 2
2* 1 + 2 = 4
4* 2 + 3 = 11
So the next number is
11 * 3 + 4 = 37

- Khushboo October 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

2* 0 + 1 = 2?
you are so funny.

- Anonymous October 27, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

yes he is right.. (any no)^0=1 :. 2^0=1
:. 2^0+1=2

- jayu August 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

oh sorry it's 2*0 so 2*0+1=2

- jayu August 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

2*0+1=1

- jayu August 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

2* 0 + 1 = 2 ?

- bogdan.cebere October 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you explain a little bit how you got 50,28,67 and 18?

- Anonymous October 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

2*0+1=1

- jayu August 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think since the series given was short, the purpose of the question was to rather see how many solutions a candidate can come up with, than getting the exact solution they were looking for. It might be a trick question -- just saying.
However, here's how I would do it:
2,2,4,11 -- the difference between consecutive terms is: 0,2,7... which can be looked at as:

2^0 -1 = 0
2^1 -0 = 2
2^3 -1 = 7
so the next difference would be:
2^4 -0 = 16

which gives the next term as 11+16 = 27.
I've never played around with the base x fibonacci, neither heard of it before... but whoever thought about it... RESPECT! ;)

- Swap July 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

u hav taken powers in a series of 0,1,3,4......
hw?????????????????(no regular seq.)

- rajesh rai July 25, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

2,2,4,11 the diff bt conseccutive terms is 0,2,7
0^1+1=2
2^2+3=7
7^3+5=348
therfore the next number in the series is 359
2,2,4,7,11,359

- bala July 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

sry the final series is 2,2,4,11,359

- bala July 28, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

pehle toh yeh batao..jayda dimag aa gaya hai kya
kuh bhi bana rahe hooo aur hum man le..

- gujar August 02, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Bala - 0^1=1 and not 1.

- Yash September 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry, 0^1=0 and not 1.
So, 0^1+1=1 and not 2 as you've written.

- Yash September 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

@bala will u explain how u chose the powers of 0,2,7

- amudhavelu August 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Numbers : 2,2,4,11
Difference : 0,2,7
sequence :
0 = 0^0
2 = 1^1 + 1^0
7 = 2^2 + 2^1 + 2^0
Next number in sequence of differences : 3^3 + 3^2 + 3^1 + 3^0 = 40
Next Number in the original Sequence = 51 (40 + 11)

- Ashwin August 26, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

0^0=1 and not 0.

- Yash September 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

if we take 7 as a base then solution will be
a1=2;
a2=2;
a3=a1+a2;//a3=2+2=4
a4=a1+a2+a3;//a4=2+2+4=8(in decimal)

/*
8=11(in base 7)
*/
a5=a1+a2+a3+a4//a5=2+2+4+11=19(in decimal)
/*
19=25(in base 7)
*/
hence ans may be 25

- mujeeb August 29, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

U said a5=a1+a2+a3+a4
a4=8

then
a5=2+2+4+8=16

to the base 7, it will become 22 only na ??

- Sree July 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Numbers : 2,2,4,11
Difference : 0,2,7
sequence :
0 = 0*0
2 = 1*1 + 1
7 = 2*+2+1
?=3*3+3+2+1
?=15
Next number in sequence of differences is 15
Next Number in the original Sequence is 26

- Anonymous January 31, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2, 2, 4, 11
First set of Differences = 0,2,7
Second set of Differences (of the first difference set) = 2,4,.... ie 2*1 = 2, 2*2 = 4, or 2^1 = 2, 2^2 = 4
so assuming the next difference is either of the following -
2*3 = 6, OR 2^3=8
The next number in the Second set of differences would either be 6 or 8

ie 2,4,6 or 2,4,8

Then the next number in the First set of differences would either be -

7+6= 13 OR 7+8 = 15

Last number of original series could either be -

11+13 = 24, or 11+15=26

And finally the series itself might be -

2,2,4,11,24
OR
2,2,4,11,26

- shaggy August 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

answer is 37

- kanwar singh August 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2,2,4,11
dist[] = {0,2,7}
solution: dist[n]= (3n^2-5n)/2+1
so the dist[4]=15
so the next num is 26

- Anonymous September 10, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

23

- amit October 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

g(n) = 2 for n=0;
g(n) = g(n-1) + f(n-1) for n>0
f(n) = n * n + (Sum of i where i runs from 0 to n)

g(0)=2
g(1) = g(1-1) + f(1-1)
       = g(0) + f(0)
       = 2 + ((0*0)+(0))
       = 2
g(2) = g(2-1) + f(2-1)
       = g(1) + f(1)
       = 2 + ((1*1)+(1+0))
       = 2 + (1 + 1)
       = 4
g(3) = g(3-1) + f(3-1)
       = g(2) + f(2)
       = 4 + ((2*2)+(2+1+0))
       = 4 + (4 + 3)
       = 11
g(4) = g(4-1) + f(4-1)
       = g(3) + f(3)
       = 11 + ((3*3)+(3+2+1+0))
       = 11 + (9 + 6)
       = 26

- neo October 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1 1 2 15 104 find next no

- Anonymous January 16, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Sort the given numbers in ascending order (Say as 2 , 4 ,6 7)
2. Represent them in binary (0010,0100,0110,0111)
3. Represent all the once in the set as set of number (say 2,3,{2,3},{1,2,3})
4. Take the once from the first set and remove them from all sets and make a new set
a. Take out 2 so new set is {3,{3},{1,3}}
b. Now Take out 3 so new set is {1}
c. Now take out 1 and it is done
So the answer is {0010,0100,0001} i.e 2,4,1

- Raghunandan Ghagarvale February 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class TestSeries {

public static void main(String[] args) {
seriesTest1();
}

public static void seriesTest1(){
int arr[]={2,2,4,11,26};
for(int i=0; i<arr.length; i++) {
int j = i * i + getFact(i);
System.out.println(arr[i]+j+"->"+i+"->"+j);
}
}

public static int getFact(int factInput) {
int response = 0;
for(int i=factInput;i>=1; i--) {
response += i;
}
return response;
}
}

- abdul.professional October 19, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

There is another way to do it. Answer is 61,

Explanation :

Given number series, 2,2,4,11
Using factorial, leave the first number from the series. and add other numbers in the series with the previous given number.

Example, factorial of 2 is 1,2
Now Leave the the 1st number and add with the previous number. Previous number empty. So,
(1) 2 + 0 (previous number) = 2
(1) 2 + 2 (previous number) = 4
(1) 2 + 3 + 4 + 2 (previous number) = 11
(1) 2 + 3 +... +11 + 4 (previous number) = 61

- Raja October 31, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

method of differences taught in elementary schools in enough .

- saru95 July 02, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

fibonacci series in base 5
a1=2, a1=2
a3=2+2=4
a4=2+4=6(in base 10)=11(base 5 [5*1+1])

- satish varagani October 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

can you explain little bit more??

- nava October 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

take 5 ary system it consists digits 0,1,2,3,4
(for example binary system contains 0,1 and decimal system contains 0 to 9)
lets take fibonacci series with a1=2 and a2=2
then a3= 2+2=4
a4= 2+4= which is six but 5 ary system doesn't contain six as a digit
how can six can be represented using 5 ary system??
11 = 5*1 + 1*1

- satish varagani November 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

so the next no. is 20?

- shahabaz January 06, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More