We are assuming that the sweets are selected at random. The question says that the sweets are eaten, so we are also assuming that they aren't put back into the bag. The total probability of selecting the two orange sweets is the product of the two individual probabilities of an orange sweet being taken each time a sweet is taken:
1, All of the sweets are in the bag
There are n total sweets in the bag, and of these there are 6 orange sweets. Thus the probability of selecting an orange sweet from this bag is 6/n.
2, There is one fewer orange sweets in the bag
There are now n-1 total sweets in the bag, and of these there are 5 orange sweets. Thus the probability of selecting an orange sweet from the bag now is 5/(n-1).
The total probability of selecting two orange sweets consecutively is therefore 6/n * 5/(n-1), which the question gives as being 1/3. Thus we are left with:
6/n * 5/(n-1) = 1/3 => n^2 - n - 90 = 0