Jump to content
Join the Unexplained Mysteries community today! It's free and setting up an account only takes a moment.
- Sign In or Create Account -

Do you want a Nobel Peace Prize?


Holyspirit

Recommended Posts

logo_transparent_small.png

I put together some python code that outputs if a prime produces a special Mersenne Prime number.  Mersenne Prime Numbers are those that utilize a prime as its power raised to produce the Mersenne Prime.  For instance this formula can make a Mersenne Prime and sometimes not 2^n-1 so 2^3-1 = 7 and 7 is a Mersenne Prime, however 2^11-1 = 2047 since 2047 is not a prime number, it is composite and even though 11 is a prime number it fails to produce a Mersenne Prime Number and that's the conundrum with 2^n-1.

If you can make this code run for every prime number inputted or entered and the output returns in under 4 seconds consistently for every prime numbers entered into the trillions you would be Famous and very Rich !

logo.gif

print('''This code will eventually relate if a prime number is or is
not a Mersenne Prime.  The problem is with large numbers and 
division of factors and so as with Prime numbers starting at 29
the time slows down on input.  Anyone who can make this 
code respond to every prime number of trillions of digits
consecutively in less than 4 seconds, that reports back correct
statements for prime numbers would become
famous and win a Noble Peace Prize!''')
print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
print('_________________________________________________')
import time
from math import floor
 
def divSum(n):
   total = 1
   i = 2
   while i * i <= n:
      if n % i == 0:
         total += i + floor(n // i)
      i += 1
 
   return total
   
#def solve(p, q):
#   return divSum(q) == divSum(q)
while True:
	start_time = time.time()
	p = int(input("Enter a prime number for an attempt to produce a Mersenne Prime Number: "))
	h = (pow(2,p-1)*2-1)*(pow(2,p-1))
	m = (((p - 1) % 9 + 1 if p else 0))
	q  = (pow(2,p-1)*2-1)*(pow(2,p-1))
	y = (((q - 1) % 9 + 1 if q else 0))
	if (divSum(q))== h:
		

		print(p,'= n and this number produces a Mersenne Prime 2^n-1')
		e = int(time.time() - start_time)
		print('{:02d}:{:02d}:{:02d}'.format(e // 3600, (e % 3600 // 60), e % 60))

 

Edited by Tom O'Neil
  • Like 1
Link to comment
Share on other sites

 
3 hours ago, Tom O'Neil said:

If you can make this code run for every prime number inputted or entered and the output returns in under 4 seconds consistently for every prime numbers entered into the trillions you would be Famous and very Rich !

Are you saying the code doesn't work or it's too slow?

Link to comment
Share on other sites

floor(n // i)

'//' is floor division.  No need to call floor on the result.

https://www.python.org/dev/peps/pep-0238/

 

	h = (pow(2,p-1)*2-1)*(pow(2,p-1))
	m = (((p - 1) % 9 + 1 if p else 0))
	q  = (pow(2,p-1)*2-1)*(pow(2,p-1))
	y = (((q - 1) % 9 + 1 if q else 0))

What is this doing? A lot of redundant calculations here.

From what I can tell Python does very few optimizations.

 

Edited by Rlyeh
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

You might also want to place 'start_time' after calling input(), at the moment your measurement includes the time it takes for the user to input.

Edited by Rlyeh
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

There are 54 prime numbers below 256:

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251]

 

Quote

A 256-bit private key will have 115,792,089,237,316,195,423,570,985,008,687,907,853,269,
984,665,640,564,039,457,584,007,913,129,639,936 (that’s 78 digits) possible combinations. No Super Computer on the face of this earth can crack that in any reasonable timeframe.

Even if you use Tianhe-2 (MilkyWay-2), the fastest supercomputer in the world, it will take millions of years to crack 256-bit AES encryption.

That figure sky-rockets even more when you try to figure out the time it would take to factor an RSA private key. A 2048-bit RSA key would take 6.4 quadrillion years (6,400,000,000,000,000 years) to calculate, per DigiCert.

https://www.thesslstore.com/blog/what-is-256-bit-encryption/

This is the kind of problem you are trying to solve.

  • Thanks 1
Link to comment
Share on other sites

If it involves math I will pass. I just despise math.

Link to comment
Share on other sites

  • 4 months later...
On 3/3/2021 at 8:38 AM, Rlyeh said:

floor(n // i)

'//' is floor division.  No need to call floor on the result.

https://www.python.org/dev/peps/pep-0238/

 


	h = (pow(2,p-1)*2-1)*(pow(2,p-1))
	m = (((p - 1) % 9 + 1 if p else 0))
	q  = (pow(2,p-1)*2-1)*(pow(2,p-1))
	y = (((q - 1) % 9 + 1 if q else 0))

What is this doing? A lot of redundant calculations here.

From what I can tell Python does very few optimizations.

 

To my understanding Python has many libraries that aid in mathematical computation--it's the code that likely needs optimization.

@Tom O'Neil

I am not trying to come across as rude, but

1.) Did you actually write this code?

2.) Assuming the answer to the first question is "Yes", how much experience do you actually have with Python/programming?

3.) Can you explain to us in great detail why you performed the calculations in the ways demonstrated above? I noticed you never actually answered @Rlyeh's inquiry into what the code is actually doing.

Edited by Nuclear Wessel
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

If "copy" = true 

then 

goto "paste"

else 

run (end) 

print : goodbye cruel world 

end

~

Link to comment
Share on other sites

On 3/4/2021 at 1:36 AM, Scholar4Truth said:

If it involves math I will pass. I just despise math.

Maths despises me.

I am always impressed when people post all the calculations they do, often to achieve something which is obscure to me. 

Link to comment
Share on other sites

 
3 hours ago, Nuclear Wessel said:

To my understanding Python has many libraries that aid in mathematical computation--it's the code that likely needs optimization.

However even compared to many programming language implementations, the main Python bytecode compiler does very few optimizations, even when using it's -O flag.

https://godbolt.org/z/r9obhfdMq

From the bytecode the redundant calculations and variables are still being evaluated even though they are never used.

Edited by Rlyeh
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.