To determine all positive integers n such that xy+1≡0(modn) implies x+y≡0(modn), we proceed as follows:
1. **Assume xy+1≡0(modn)**:
xy≡−1(modn)
2. **Consider x and y such that x is coprime to n**:
Since x is coprime to n, there exists an integer x−1 such that:
xx−1≡1(modn)
3. **Express y in terms of x**:
From xy≡−1(modn), multiply both sides by x−1:
y≡−x−1(modn)
4. **Check the condition x+y≡0(modn)**:
Substitute y from the previous step:
x+y≡x−x−1≡0(modn)
This implies:
x≡x−1(modn)
5. **Analyze the implications of x≡x−1(modn)**:
This means x2≡1(modn). Therefore, x must be a solution to the equation:
x2−1≡0(modn)
(x−1)(x+1)≡0(modn)
6. **Determine the structure of n**:
For the above equation to hold for all x coprime to n, n must be such that every x coprime to n satisfies x2≡1(modn). This is true if and only if n is a product of distinct primes, specifically n=2.
7. **Verify n=2**:
If n=2, then:
xy+1≡0(mod2)⟹xy≡−1≡1(mod2)
Since x and y are integers, x and y must both be odd, and thus:
x+y≡1+1≡0(mod2)
This satisfies the condition x+y≡0(mod2).
Therefore, the only positive integer n that satisfies the given condition is n=2.
The final answer is 2.