We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The first term, (999! % P) can be calculated as you told Sir, but how do I calculate the next term, ((499! * 500!) (P - 2) % P).....?? Can you please explain me mathematically step-by-step, exactly as you did above....??
P.S. ..... Sir, the above mentioned content means EXACTLY the same as your answer to a discussion.... I got this same doubt when I tried to understand your answer, Sir.... But I could'nt, then I ignored.... But as too many Q's were demanding this technique, I had to ask... I hope you understand... Please clarify my confusion Sir.... Thanks a lot for the reply Sir...! :-)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Permutations
You are viewing a single comment's thread. Return to all comments →
Yes abhiranjan Sir.... I understand that very well.... What asked was... Take a test case where M = 500, N = 500, that sums to,
(999!) / (499! * 500!)
Then our formula becomes,
((999!) / (499! * 500!)) % P = ((999! % P) * ((499! * 500!) (P - 2) % P)) % P,
The first term, (999! % P) can be calculated as you told Sir, but how do I calculate the next term, ((499! * 500!) (P - 2) % P).....?? Can you please explain me mathematically step-by-step, exactly as you did above....??
P.S. ..... Sir, the above mentioned content means EXACTLY the same as your answer to a discussion.... I got this same doubt when I tried to understand your answer, Sir.... But I could'nt, then I ignored.... But as too many Q's were demanding this technique, I had to ask... I hope you understand... Please clarify my confusion Sir.... Thanks a lot for the reply Sir...! :-)