<s>[INST] Knowing that $n= 3598057$ is a product of two different prime numbers and that 20779 a square root of $1$ mod $n$, find prime factorization of $n$. 
Knowing that $n= 3598057$ is a product of two different prime numbers and that 20779 is a square root of $1$ mod $n$, find prime factorization of $n$.

What I have done so far:
$n = p \cdot q$
$x^2 \equiv 1\pmod{n}$
$x^2 -1 \equiv 0\pmod{n}$
$(x-1)(x+1) \equiv 0\pmod{n}$
$x-1 = 20779 \lor x + 1=20779$
I have also noticed that:
$(x-1)(x+1) \equiv 0\pmod{p \cdot q}$
$(x-1)(x+1) \equiv 0\pmod{p} \land (x-1)(x+1) \equiv 0\pmod{q}$
But I have no idea what to do next. Any hints?
 [/INST] From the condition
(x-1)(x+1)=0 mod n
you can conclude (a) n divides (x-1), or (b) n divides (x+1), or (c) some factor of n divides (x-1) and some other factor of n divides (x+1)
Since (a) and (b) are ruled out (x is not plus or minus 1) we get two factors as
f1 = gcd(x-1,n)
f2 = gcd(x+1,n)
If n is not known to be a product of two primes, then one will try to factor f1 and f2 or prove their primality.
</s>