I have an arbitrary number $x$. I would like to compute a number that is coprime to $x$ that's close(ish) to the square root of $x$. I don't need to find them all, and factoring $x$ is expensive. I just need one number. I could also check a few primes near the square root of $x$, but computing primes and storing primes is expensive.
Constant time and space, preferably.
Since calculating the gcd of two arbitrary number isn't expensive, you can practically brute force it.
Algorithm:
n.r.gcd(n,r)=1. If yes, returnrand exit.1tor, and repeat step3.Python:
Does it in fraction of a second.
Try it online!
Sample output: