Finding CB numbers


why is it failing at some cases?