Finding CB Numbers DOUBTS

Hi,
This is my code :


In the last test case it is showing run time error. Please help me correct my code. Rest of the test cases are correct.