mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Factoring (https://www.mersenneforum.org/forumdisplay.php?f=19)
-   -   Python script for search for factors of M1277 using random k-intervals (https://www.mersenneforum.org/showthread.php?t=25941)

 Viliam Furik 2020-09-10 13:20

Python script for search for factors of M1277 using random k-intervals

[CODE]import numpy as np
from random import randint

f = open("m1277.txt", "a")

def tf1277(k, r):
expos = np.zeros((4, r), int)
p = 1277
y = 0
z = 0
e1 = 2555
e2 = 3832
e3 = 7663
e4 = 8940
pbinary = []
q = p
while q > 0:
if q % 2 == 0:
pbinary.append(0)
q //= 2
if q % 2 == 1:
pbinary.append(1)
q //= 2
pbinary.reverse()
for x in range(4):
for prime in [3, 5, 7, 11, 13, 17, 19, 23, 29]:
for a in range(prime + 5):
if x == 0:
e = e1
elif x == 1:
e = e2
elif x == 2:
e = e3
else:
e = e4
if ((a + k) * 10216 + e) % prime == 0:
c = a
while c < r:
expos[x][c] = 1
c += prime
break
for a in range(len(expos[0])):
if expos[0][a] == 0:
c = 1
kp = (k + a) * 10216 + 2555
for d in pbinary:
c **= 2
if d == 1:
c *= 2
c %= kp
if c == 1:
print("-------------------------")
print("factor = ", kp)
print("k = ", (kp - 1) // 2 // 1277)
f.write("\n")
f.write("factor = " + str(kp))
f.write("\n")
f.write("k = " + str((kp - 1) // 2 // 1277))
f.write("\n")
quit()
if y == 1000:
y = 0
z += 1
print(z * 1000)
y += 1
for a in range(len(expos[1])):
if expos[1][a] == 0:
c = 1
kp = (k + a) * 10216 + 3832
for d in pbinary:
c **= 2
if d == 1:
c *= 2
c %= kp
if c == 1:
print("-------------------------")
print("factor = ", kp)
print("k = ", (kp - 1) // 2 // 1277)
f.write("\n")
f.write("factor = " + str(kp))
f.write("\n")
f.write("k = " + str((kp - 1) // 2 // 1277))
f.write("\n")
quit()
if y == 1000:
y = 0
z += 1
print(z * 1000)
y += 1
for a in range(len(expos[2])):
if expos[2][a] == 0:
c = 1
kp = (k + a) * 10216 + 7663
for d in pbinary:
c **= 2
if d == 1:
c *= 2
c %= kp
if c == 1:
print("-------------------------")
print("factor = ", kp)
print("k = ", (kp - 1) // 2 // 1277)
f.write("\n")
f.write("factor = " + str(kp))
f.write("\n")
f.write("k = " + str((kp - 1) // 2 // 1277))
f.write("\n")
quit()
if y == 1000:
y = 0
z += 1
print(z * 1000)
y += 1
for a in range(len(expos[3])):
if expos[3][a] == 0:
c = 1
kp = (k + a) * 10216 + 8940
for d in pbinary:
c **= 2
if d == 1:
c *= 2
c %= kp
if c == 1:
print("-------------------------")
print("factor = ", kp)
print("k = ", (kp - 1) // 2 // 1277)
f.write("\n")
f.write("factor = " + str(kp))
f.write("\n")
f.write("k = " + str((kp - 1) // 2 // 1277))
f.write("\n")
quit()
if y == 1000:
y = 0
z += 1
print(z * 1000)
y += 1

while True:
tf1277(randint(58000000000000000, 2 ** (1277 / 2) / 1277 / 2), 1000000)
[/CODE]

Hello, I have made the above Python script, that is called with random starting k value, and then tests about 1263000 sived-out k's above that value. It uses a grid of zeroes to sieve k's and combines the facts that factors must be 2*k*p+1 and also 1 or 7 (mod 8) - so it only tests factors that are 2555, 3832, 7663, 8940 (mod 10216).

If there is a mistake (either logical or mathematical) in my script, I'll be grateful for pointing out. I would also be grateful if somebody could help me with making the code runnable on a Nvidia GPU with CUDA (or in OpenCL, if it's easier), without necessarily using FFT or Barrett multiplication. (But if somebody is willing to explain, I'll be happy to listen, or read...).

And for the last, if you want, you can try to find the factor yourself with that code. It takes my CPU about 12 seconds on average to go through random range of size 10216000000 (that is difference between largest and smallest k tested). So if I was to randomly check the equivalent number of ranges (untested range from 2^67 to 2^639 divided by range size 10216000000), it would take me... about 2*10^172 years :down: . But if more people engage in search, probability increases (unfortunately it's only slight change).

So if you want to help, you can run the script any time you like. If you want to help more, you can help with improving the speed of the script.

 retina 2020-09-10 13:56

Running this code is a fantastic way to waste power/time/money/energy. :tu:

Random TF for this number is pointless. And trying to "optimise" a scripting language is equally pointless.

You need another method (not TF), and you need another language (not a scripting language).

 mathwiz 2020-09-10 14:58

[QUOTE=Viliam Furik;556632]if more people engage in search, probability increases (unfortunately it's only slight change).

So if you want to help, you can run the script any time you like. If you want to help more, you can help with improving the speed of the script.[/QUOTE]

You'd probably have a better chance of being struck by lightning 10 times and winning the lottery all on the same day.

The only hope for M1277, with presently known factoring techniques, is a mountain of ECM or (eventually) SNFS.

 Runtime Error 2020-09-10 21:57

Fun! I have a machine that is ram-bottle-necked for Prime95. So far, running this too doesn't seem to affect the iterations per second. I'll leave it on for a week or so and perhaps lightning with strike! (Or strike 10 times, per the comment above. But I will probably not buy the requisite lotto ticket.)

 VBCurtis 2020-09-10 22:15

How long will it take this program to search for all 70-digit factors? Or, most of them? How about 1% of the 70-digit range?

ECM on this number has ruled out factors smaller than about 67 digits, and a 70-digit or smaller factor is unlikely. So, I'm not even sure you should set it to look at 70 digits- maybe 73 is smarter. How many k's are there that make 73-digit candidate factors?

 firejuggler 2020-09-10 22:57

we are looking at a 245 bit factor? hmmm
66-67 bits TF took 11 704 Ghz/D, and it double each bit.
so 245-67=178. Sooo 2^178*11 704= 4.484e57 Ghz/D for the last bit. Not counting all that is before it,
Which double it. Lets handwave this a bit and it come to 9e57Ghz/D.

Problem: The fastest current TF card,will give you 6e3Ghz/D by day. so, AFAIK, it would take 1.5e54 Day,

About 3e41 time the duration since the beginning of the universe. Thats, by TF only. PM1 is almost excluded because of its requirement.

 VBCurtis 2020-09-11 00:50

So, one fast GPU can spend 1e54 days to have roughly a 1 in 250 chance to find a factor.

Or, you could run regular ECM with large bounds (B1=3e9 or bigger) and actually contribute non-useless work.

 Uncwilly 2020-09-11 01:10

Is there enough data yet to suggest that Mersenne non-primes have a higher likelihood to have 3 only factors vs 2 only?

 Batalov 2020-09-11 01:24

[QUOTE=Uncwilly;556682]Is there enough data yet to suggest that Mersenne non-primes have a higher likelihood to have 3 only factors vs 2 only?[/QUOTE]
Many more Mersenne non-primes have a thousand factors. And even more have a million factors! :rolleyes:
[SPOILER]Infinity is a rather large thing.[/SPOILER]

 LaurV 2020-09-11 10:06

[QUOTE=firejuggler;556679]Problem: The fastest current TF card,will give you [COLOR=Red][B]1.2e4[/B][/COLOR]Ghz/D by day.[/QUOTE]
Fixed it for you. Not that would change much, haha.

One-line pari "search by q" (as posted a lot of times in the forum) with a parfor and a random start would be faster that the posted script.

 Dr Sardonicus 2020-09-11 13:22

[QUOTE=Uncwilly;556682]Is there enough data yet to suggest that Mersenne non-primes have a higher likelihood to have 3 only factors vs 2 only?[/QUOTE]
[i]Exactly[/i] three versus [i]exactly[/i] two prime factors, not sure. Exactly two versus more than two, long-known data suggest "no contest."

I'll assume, for the sake of discussion, that you mean Mersenne numbers M[sub]p[/sub] with [i]prime[/i] exponent p. For composite exponents n, the algebraic factorization alone is very likely to provide more than two proper factors, which, in turn, are very likely to provide more than two prime factors.

From an old factorization table of 2[sup]n[/sup] - 1 for odd n < 1200 I have on file, a quick scan finds that M[sub]p[/sub] was known to be prime for 13 odd prime p, known to have exactly two prime factors for 38 prime p, and known to have 3 or more prime factors for 143 odd prime p. The table lists M[sub]1061[/sub] as a C320 so the number of factors was only known to be 2 or more at the time.

It seems that 2[sup]1061[/sup] - 1 was subsequently found to be the product of two prime factors, so M[sub]p[/sub] is known to be prime for 13 odd prime p < 1200, known to have exactly two prime factors for 39 odd primes p < 1200, and known to have 3 or more prime factors for 143 odd prime p < 1200. That accounts for all 195 odd primes p < 1200.

So I would say that the data suggest that more than two factors is much more likely than exactly two.

There are only about 400 primes p for which the [i]exact[/i] number of factors of 2[sup]p[/sup] - 1 is known or "probably" known. I'm too lazy to check for how many p the number of factors is known to be [i]at least[/i] 3.

All times are UTC. The time now is 21:09.