# Help to DEBUG KBIGNUM

Can anyone help me to debug the code here? I spent whole day on this problem, but I am unable to get it right.

I am AWARE of it failing on some test cases, and I know what those test cases are. I specifically need help in debugging the code and correcting it. I used the approach described by @gkcs in his video editorial, but I think I messed up somewhere.

I would be grateful if anyone could help.

Why donâ€™t you try the approach given on this link? Itâ€™s pretty simple than your one!

And sorry, I couldnâ€™t debug your code!

1 Like

@vijju123

yes,at hackerrank it is givenâ€¦but let me debug,if I could.

1 Like

I wish to do it via approach given by gkcs in his video editorial. Much more because I am unable to figure out whats wrong, I want to know where I am lacking. Of course, other approach might be simpler, but my motive is to find and rectify my mistakes and then to solve the problem. Thanks for your considerations though!

I would appreciate that dear! Try to watch gkcsâ€™ explanation in his video if you are unable to get my logic or â€śwhy did I do thatâ€ť.

Hello @vijju123 !
I canâ€™t debug your code but I was having WA too initially, it was due to the following reason.
1> I proved the answer to be of the form A.((10^(lenA . N) - 1) / (10 ^ lenA - 1)). Now , I knew that we canâ€™t just simple do a modulo operation in division so I was finding the inverse modulo with fermatâ€™s little theorem, which was a wrong choice because it works only if the number whose inverse you want to find and M are co-primes which was not the case here. So, if you have that logic be careful. Also, Modulo operations too.
Try this tc
1
526 996 956577277
output: 535743493

1 Like

I sincerely thank all the concerned people for their time.

I have added a solution to the video description, just in case

Thats what I call icing on a cake!! Thanks a lot bud!! Really appreciate the time you devoted to it!!!

//