The fastest method of finding the inverse of a 1024 bit number (N) i.e. 1/N?

136 Views Asked by At

I have been trying to find inverses of large integers (could be upto 2048 bits), such that 1/N has a minimal period p and n its length in binary. (what i actually am interested in finding is the length of the minimal period n)

Now could someone suggest a faster method of either obtaining the inverse upto a precision that's greater than n or some other method of finding n that doesn't take ages to compute...

Further restrictions on N are that it will always be a semi prime number. however the factors are unknown and factorization would take a lot of time thereby gets infeasible.

2

There are 2 best solutions below

1
On BEST ANSWER

Use Newton's method to divide quickly. https://en.wikipedia.org/wiki/Newton%27s_method and watch this video https://www.youtube.com/watch?v=AoVI9NWegWw

0
On

I asked a more general version of this question a while ago, and going by the answer I got, to get the length of the minimal period you first factor out all factors $2$ from $N$ to get $N'$ (which is feasible, especially in binary).

The answer is then equal to the multiplicative order of $2$ modulo $N'$. Whether there is a good algorithm for this, I don't know, but it's such a common problem that someone ought to have thought of something clever.