View Single Post

  #5 (permalink)  
Old 01-05-2008, 10:36 PM
Interviews Interviews is offline
Junior Member
 
Join Date: Jan 2008
Posts: 2
Interviews is on a distinguished road
Answer to this is not quite intuitive - at least for me - however check the answer below

1) 1
This number has one (1), 1
So, the next number is
2) 11
This number has two (2), 1's
so, the next number is
3) 21
This number has one(1), 2 and one(1),1
so, the next number is
4) 1211
This number has one(1), 1, one(1), 2 and two (2),1's
so, the next number is
5) 111221
This number has three(3), 1's, two(2), 2's and one (1),1
so, the next number is
6) 312211
This number has one(1), 3, one(1), 1, two (2),2's and two (2), 1's
so, the next number is
7) 13112221

So, on so forth.... Hope the logic is clear ...
another number question available here
__________________
ELECTRIC Go get it! Embedded Interview Questions
Reply With Quote