Let $q$, $p$ be distinct primes. Determine unique $n$ in $\{q, q+1, \ldots, q+p-1\}$ such that $\gcd(p, n) > 1$

52 Views Asked by At

Is there a way to determine, given distinct primes $q, p$, the unique $n \in \{q, q+1, \ldots, q+p-1\}$ such that $\gcd(n, p) \gt 1$?

2

There are 2 best solutions below

6
On BEST ANSWER

If we have $p$ consecutive numbers, exactly one is divisble by $p$, which is equavalent that it is not coprime to $p$.

If $p<q$ , and $s\equiv q \mod p$ with $0<s<p-1$, then take $q+p-s$

If $p>=q$ , $p=q+(p-q)$ is contained in the given set because of $0\le p-q<p-1$

In short , calculate $q$ modulo $p$ , denote the result $s$ and take $p+q-s$.

So, a formula would be $p+q- (q\mod p)$

0
On

The question doesn't make much sense, but... divide $q$ by $p$:

$$q = cp + r$$

Then $n = (c+1)p$.

Does this determine $n$?

If you need a formula: $n = \lceil \frac q p \rceil \times p$.