Python Forum
Need help to identify Mersenne Primes, I do need a search pattern.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help to identify Mersenne Primes, I do need a search pattern.
#1
Hi,

I have been struggling with this code for four weeks and I cannot seem to rap my head around how to search for certain numbers after I run the code in python37. I can return factors for numbers I'm searching for but only if I type in a specific number. For instance if I want to see a print out of a factor for 2**11-1 which equals 23 I have to type in 2.

I do have two pieces of code the second piece allows you to see the range of items in the list and you can print factors for Non-Mersenne Primes!

Can someone help me the the second piece of code for subtraction and division? So I can output this in an automated fashion:)

Say you need to know the math for 1682 using P=29 then P=29**2*2 = 1682


'''A program which identifies factors of non-Mersenne Primes(other than 1 and itself), when a prime uses 2^p-1  '''



while True:
    
    
        

    composites=[]
    list1z = composites
    p = int(input('Enter a prime number to test for a factor : '))
    y = int(input('Enter the start range if your going for big factors make a large number: '))
    n = int(input("Enter the end range : "))
    
    
    
#    e = int(input('Enter the end range if your going for big factors make a large number: '))


    

    
    
    positive_n = abs(n)
    for num in range(positive_n+1):
        
        if num > 1:
            for i in range(1, num,1):
                if (num % i) == 0:
                    if n > 0:
                        composites.append(num)
                    else:
                        composites.append(-num)
                    break
                j = ((((((num*p+1)*p)+p)//p)//p))
                
                
                
                
                
                    
    

                
    list1z = composites
#    print("\ncomposites from {} to {} \n list1z = {}".format(int(positive_n/n), n, list1z))
    list1z = composites
#    print("\ncomposites from {} to {} \n list1z = {}".format(int(positive_n/n), n, ([str(i) for i in list1z])))
#    print([str(i) for i in list1z])
    




    final_list = list()
    for index, i in enumerate(list1z):
        final_list.append(index)
        final_list.append(i)
        
    list1z = composites
    print("\ncomposites from {} to {} \n list1z = {}".format(int(positive_n/n), n, final_list))
    list1z == [(((((num*p+1)*p)+p)//p))]
    if (((((num*p+1)*p)+p)//p//p)) in list1z:
       print ((((((num*p+1)*p)+p)//p)-2)+1)
       
       n = (((((num*p+1)*p)+p)//p//p)) 
       
       
#       while n > 0:
#           print(list1z.pop(+(((((num*p+1)*p)+p)//p//p)) ))
           
'''Input a prime number P, Subtract all numbers in left column by P, then divide all numbers by far right column, if you find a non fraction to come up
first in the list then that number is a non_Mersenne Prime Number which does not produce a prime number according to this formula 2^p-1 and
the middle number is the factor!!!!

Happy Hunting, Merry Christmas from Tom O'Neil 2019 copyright all Mersenne Primes reserved on tap :)'''

print('''Input a prime number P, Subtract all numbers in left column by P, then divide all numbers by far right column, if you find a non fraction to come up
first in the list then that number is a non_Mersenne Prime Number which does not produce a prime number according to this formula 2^p-1 and
the middle number is the factor!!!!

Happy Hunting, Merry Christmas from Tom O'Neil 2019 copyright all Mersenne Primes reserved on tap :)''')
import math
while True:
    
    list_factors ={}
    list_numbers = {}
    list_a = []

    
    
    
    


    p = int(input('Enter a prime number to test ratio : '))
    a = (1)

    
    g = ((p**3//(.5*p)//2))
    k = ((((p**3//(.5*p)))))
    c = ((((p**3//(.5*p)//(.5*p)))))
    d = ((((p**3//(.5*p)//(.5*p)*2)-2)))
    o = (((2*p/(p**3//(.5*p)//(.5*p)//(.5*p)))))
    r = ((((p**3//(.5*p)//(.5*p)//(.5*p)))))
    m = ((((k-(((p**3//(.5*p)//(.5*p)))*o))//(p))))
    s = (round((((p*c))/p**3*100)))
    t = (round((((3+k+2*c))/p**3*100)))
    l = (p//((2)//2))
    
    
 
    
    y = int(input('Enter the start range if your going for big factors make a large number: '))
    e = int(input('Enter the end range if your going for big factors make a large number: '))


#    print (o*r)
#    print((p/2/2//2))
    h = ((p/2/2//2))
    print(p)
#    print(o)
    

    for i in range(y,e):
        
         
        
    

        
        
        
   
        new_values = { i :  ((i*p+1))}
        new_valuesf = {(((((i*p+1))*p))) : (((((i*p+1))))) }

        list_factors.update(new_valuesf)
        for item  in new_valuesf:
            if item == (((((i*p+1))*p))):
    
        
                list_numbers.update(new_values)

       
              


                print((new_valuesf) , ((k/i)*i))
                ([((int(i)-z) % (z*z)) if isinstance(i, str) else i for i in new_values])

    
    

    
     
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  identify not white pixels in bmp flash77 17 2,264 Nov-10-2023, 09:21 PM
Last Post: flash77
  guys please help me , pycharm is not able to identify my xlsx file CrazyGreenYT7 1 1,971 Jun-13-2021, 02:22 PM
Last Post: Larz60+
  Need to identify only files created today. tester_V 5 4,547 Feb-18-2021, 06:32 AM
Last Post: tester_V
  Need to identify sheet color in excel workbook chewy1418 2 2,444 Feb-14-2020, 03:26 PM
Last Post: chewy1418
  Syntax Error : I can't identify what's wrong! caarsonr 11 6,134 Jun-10-2019, 11:18 PM
Last Post: Yoriz
  Identify two specific words next to each stahorse 9 4,083 Apr-26-2019, 09:59 AM
Last Post: perfringo
  Perfect Number formula in Python Question an Mersenne Numbers Pleiades 5 5,964 May-16-2018, 04:56 PM
Last Post: Pleiades
  Convert Vba Primes to Python Primes jackhj 1 2,388 Apr-18-2018, 12:19 AM
Last Post: Larz60+
  Identify Hidden rows in xls ayonsarkar 2 11,034 Apr-10-2018, 08:33 PM
Last Post: ljmetzger
  Sophie Germain Primes PythonLamer 7 5,529 Oct-28-2017, 05:27 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020