I have to calculate the value of (a/b) mod p where p may or may not be a prime number. For p being prime, I can simply find (b inverse for mod p) using euclid theorem or little fermat theorem, and perfrom (a * inverse(b)) % p. But in case p is not prime, how can I find the solution? I think there is a method by doing prime factorization of p and then using chineese remainder theorem but not sure about it. Can anyone help how can I solve this problem?
a and b both are less than p.