PALIN:getting WA

i have tried many possible test cases, for which i am getting correct answer. please tell where my answer is going wrong. my solution-

I wonder its a wrong answer while I am getting a RTE for input 9.


Anyway… check your code for this input…

no its coming cottect for 1 and 9.
what is RTE?

Run Time error. Check the link. I ran it on Ideone.