I want to calculate value of
F(N) = (F(N-1) * [((N-R+1)^(N-R+1))/(R^R)]) mod M for given values of N,R and M.
Here A^B shows A power B and NOT any Bitwise operation
Here M need not to be prime.How to approach this question?Please help because if M was prime that it would not have beed so difficult to find inverse of R^R mod M.
But as M can be any value ranging from 1 to 10^9.I am not able to tackle this problem.
N can be between 1 and 10^5 and R is less than or equal to N.