A.D.
Well, I'm going to assume that you've done the obvious and cleaned the litterbox. A lot of cats (mine included) won't use the box if it's too dirty. Have you switched litter brands recently? Sometimes cats can be very finicky even about the litter. Or maybe you are right and he is missing his friend.
In the meantime, I would invest in a carpet shampooer and shampoo it well after he uses the carpet because if the smell is there, he will think that is where he should be using instead of his box.