The number of ways in which 6 pencils can be distributed between two boys such that each boy gets at least one pencil is 
The number of ways in which 6 pencils can be distributed 
  between two boys such that each boy gets at least one pencil is

I think it is 5, but the answer is 62. Where am I wrong?

The answer is indeed $5$ if one considers the pencils to be indistinguishable.
But if each pencil is distinguishable (say, a different color) then there are $2^6 = 64$ ways to distribute the pencils, $2$ of which leave one boy with no pencils. Leaving a total of $64-2=62$ ways.
The logic behind $2^6$ is that each of the $6$ pencils has $2$ places it can go. So there are $6$ factors of $2$.
