Let $n=pq$ be the prime decomposition. I am searching for $l$ such that there exists a $k$ with:
$$n^l = a \cdot 2^k + b$$ and $$ 1 < \gcd(b,n^l) < n^l$$
Edit by comment of @GerryMyerson: If $n^l = a 2^k +b = \sum_{i=0} ^r n_i 2^i$, then we require, that $b$ will be the last digits of $n^l$, hence: $$b = \sum_{i=0}^{k-1} n_i 2^i$$ Then necessarily: $$a = \sum_{i=k}^r n_i 2^{i-k}$$
Here is an example of what I mean: $$n = 3 \cdot 7 = 10101_2$$ For $l=1$ we do not find $b$. Let us look at $l=2$: Then $$n^2 = 110111001_2$$ Taking $b=3^2 = 1001_2$ which are the last digits of $n^2$, we find that $a=27=11011_2$, which are the first digits of $n^2$. This coincides with what @GerryMyerson suggested, but in general this will not be the case.
It is to me not clear that such an $l$ will exist, and how big $l$ will be compared to $\log(n)$. So if you have any idea in this direction, that would be nice.
Having such a $g=\gcd(b,n^l)$ and hoping it will be of the form $p^rq^s$ with $s \neq r$, we might divide it successively through $n$ until $g = q^m$ is a prime power, so that we have $g=q^m$ for some $m$. Recognizing this as a prime power (which can be done fast), we can compute $q$ a divisor of $n$.
I think that the running time, if the method is correct, will be $1 \le l \le t$, $\frac{t(t+1)(2t+1)}{6} \log(n)^2 = \log(n)^2 \sum_{l=1}^t l^2 = \log(n^1)^2+\log(n^2)^2+\cdots \log(n^t)^2$. Explanation: For each $l=1,\cdots,t$ we have $\log(n^l)$ digits. For each digit we compute a $\gcd(n^l,x)$ which takes time on average $\log(n^l)$.
If one can prove that $t \le \log(n)^c$, for example $t \le \log(n)^2$, then one would have a fast method to find the divisors of $n$.
It would be nice, if a better analysis of the running time is available: Here is the SAGEMATH code:
n = next_prime(randint(1,10^2))*next_prime(randint(1,10^3))
b = 2
a1 = n
ex = 0
steps = 0
g = 2*n
print log(n).N()**5
while (not is_prime_power(g)) and ex < log(n)^2:
ex += 1
N = n**ex
d = N.digits(b)
d1 = []
d2 = [x for x in d]
a1 = 0
for k in xrange(1,len(d)):
steps += 1
bit = d2.pop(0)
d1.append(bit)
#D1 = d[0:k]
#D2 = d[k:]
#print d1==D1
a1 = a1+bit*2**(k-1)
#a2 = (n**ex-a1)/2**(len(d1))
#A1 = sum([d1[i]*2**i for i in range(len(d1))])
#A2 = sum([d2[i]*2**i for i in range(len(d2))])
#print a1,a2,n**ex == A1+2**k*A2,A1,A2
print steps, steps/log(n).N()^5
if 1 < gcd(N,a1) < N:
g = gcd(n**ex,a1)
print ">",g
while not is_prime_power(g):
g = g/n
print is_prime_power(g,get_data=True)
print ex,log(n).N(),steps
break
Edit I did some experiments with primes up to $1000$ and here is the result (indicating that it can for those primes be done with $t \le \log(n)^2$:
def method(n,T):
steps = 0
g = 2*n
N= 1
ex = 0
while (not (1 < g < n) ) and ex <= T:
ex += 1
N = N*n
d = N.digits(2)
d1 = []
d2 = [x for x in d]
a1 = 0
for k in xrange(1,len(d)):
bit = d2.pop(0)
d1.append(bit)
a1 = a1+bit*2**(k-1)
steps += 1
g = gcd(N,a1)
if 1 < g < N:
if floor(log(g)/log(n)).N()==(log(g)/log(n)).N():
break
while not is_prime_power(g):
g = Integer(g/n)
p,r = is_prime_power(g,get_data=True)
if n%p ==0 and is_prime(p):
return p,ex,k,steps
return None
for p in primes(3,1000):
for q in primes(p+1,1000):
n = p*q
x = method(n,T=log(n)^2)
if x is None:
print p,q
If we set $T = \log(n)$ then the method will not work in this time for some numbers: For example: $n= 19 \cdot 43$. However with $T=\log(n)^2$ the method works for these numbers.