0
$\begingroup$

I need to find $\frac{a}{b} \mod c$.
This is equal to $(a\cdot b^{\phi(c)-1}\mod c)$, when $b,c$ are co-prime. But what if that's not the case?
To be more clear, I need $$\frac{10^{a\cdot b}-1}{10^b-1}\mod P$$

  • 0
    Were you not aware that the denominator divides the numberator? This added example changes the focus of your original question.2017-02-03

3 Answers 3

0

In general, it doesn't make sense if $b$ is not coprime to $c$. However, in your case, the fraction is actually an integer so we can make sense of it.

Not that $\dfrac{x^n-1}{x-1}=x^{n-1}+x^{n-2}+ \cdots +1$ so setting $x=10^b$ and $n=a$, you get $\dfrac{10^{ab}-1}{10^b-1}=10^{a-1}+x^{a-2}+ \cdots +1$ and you nowjust to have compute what each term is $\mod{P}$.

1

What' you're looking for is a solution to $$ bx = a \pmod c $$ If $b$ and $c$ are not coprime, write $d = \gcd(b,c)$, and write $c = (md)n$ in such a way that $md$ and $n$ are relatively prime. With the Chinese remainder theorem, it suffices to solve the system of equations $$ bx = a \pmod {md}\\ bx = a \pmod n $$ The second equation is necessarily solvable, but the first might not be.

1

Update: you edited your question to include a specific example. Here there is some ambiguity depending on whether the division is intended in the integers, or in the integers mod $m$. Let's consider a simpler case, the fraction $\ x\equiv {6}/2\pmod{\!10}.\,$ If this denotes division in the integers then $\,6/2\,$ denotes $3$ so $\,x\equiv 3\pmod{\!10}.\,$ However, if it denotes division in the integers mod $10$ then we seek the solution of $\,2x\equiv 6\pmod{\!10},\,$ i.e. $\,2x = 6+10k\,$ $\iff$ $x = 3 + 5k$ $\iff x\equiv 3\pmod{5}$ $\iff x\equiv 3,8\pmod{\!10}.\,$ Usually one can determine which is intended from the ambient context.


Generally let's consider the solution of $\ B\, x \equiv A\pmod {\!M}.\ $ If $\,d=(B,M)\,$ then $\, d\mid B,\:\ d\mid M\mid B\,x\!-\!A\,\Rightarrow\, d\mid A\ $ is a neccessary condition for a solution $\,x\,$ to exist.

If so then let $\ m, a, b \, =\, M/d,\, A/d,\, B/d.\ $ Then cancelling $\,d\,$ throughout yelds

$$\ x\equiv \dfrac{A}B\!\!\!\pmod{\!M}\iff M\mid B\,x\!-\!A \overset{\rm\large cancel \ d}\iff\, m\mid b\,x\! -\! a \iff x\equiv \dfrac{a}b\!\!\!\pmod{\!m}$$

where the fraction $\ x\equiv a/b\pmod{\! m}\,$ denotes all solutions of $\,ax\equiv b\pmod{\!m},\: $ and similarly for the fraction $\ x\equiv A/B\pmod{\!M}.\: $ Note there may be zero, one, or multiple solutions.

The above implies that if solutions exist then we can compute them by cancelling $\,d = (B,M)\,$ from the numerator $\,A,\,$ the denominator $\,B\,$ and the modulus $\,M.\,$ In other words

$$ x\equiv \dfrac{ad}{bd}\!\!\!\pmod{\!md}\iff x\equiv \dfrac{a}b\!\!\!\pmod{\! m}$$

If $\, d>1\, $ the fraction $\, x\equiv A/B\pmod{\!M}\,$ is multiple-valued, denoting the $\,d\,$ solutions

$$\quad\ \begin{align} x \equiv a/b\!\!\pmod{\! m}\, &\equiv\, \{\, a/b + k\,m\}_{\,\large 0\le k

  • 0
    I understand your approach, but I can't find gcd of $a,b$. Can you please reconsider my problem, I updated what I really needed. Sorry for the inconvenience caused.2017-02-03