code link: https://ide.codingblocks.com/s/175562
Not able to find the problem with my code
Virat is learning to calculate nCr. Dhoni gave him some n and r values to solve for nCr. As the result can be large, he asked him to print (nCr % 1000000007).
Hey @siddharth9k9 there were couple of problems with your code,
- while calculating answer you need to pass factorial of r and n-r to fastexpo instead of r and n-r
- (a*b)%mod = (a%mod * b%mod)%mod, but you were just doing (a%mod * b%mod)
Here is your code with rectifications : https://ide.codingblocks.com/s/175587
i have also added comments in the lines where i made changes.
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.