Can you tell me what's wrong in this?

you miss one case
if n1 or n2==0 then??

Modified Code

now it is passing all testcase