5th test case failed playing with Divisors is fun

please look at my code and help me
github gist attached:

you cannot divide a number after performing modulo operation… here you are divinding with 2 after modulo operation … take inverse of 2 and multiply with the number…

1 Like

now used this 500000004 instead of dividing by 2 but more test cases fail X0

I made sure that ll dosent overflow using modulo repeatedly for each term like
((a%p)*(b%p))%p

I have updated the gist

i have modified your code have a look…

that works perfectly so splittting up the multiplication was the key!!
thanks for your prompt and useful replies… :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.