Given the odd one long x, I search long yso that their product modulo 2**64(i.e. using ordinary overflow arithmetic) is 1. To understand what I mean: it could be calculated over several thousand years as follows:
for (long y=1; ; y+=2) {
if (x*y == 1) return y;
}
I know that this can be quickly solved using the advanced Euclidean algorithm, but this requires the ability to represent all the numbers involved (before 2**64, so even unsigned arithmetic would not help). Using it for BigIntegersure will help, but I'm wondering if there is a simpler way, perhaps using the advanced Euclidean algorithm implemented for positive lengths.
source
share