Small thing i made in my spare time

Discussion in 'Offtopic' started by chugga_fan, Mar 24, 2016.

  1. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    Last edited: Mar 24, 2016
    matijase and julio1237878 like this.
  2. DanPiTV

    DanPiTV Learning Omni-Tool

    Messages:
    35
    Likes Received:
    6
    Local Time:
    1:37 AM
    Im curious, what is the program? What does it do?
     
  3. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    It tests if 2^maxINT-1 is prime, i plan on adding more numbers eventually, but i made this program for one purpose and the ammount of work i put into it i thought made it a bit interesting[DOUBLEPOST=1458918986,1458907328][/DOUBLEPOST]I'm also thinking of posting regular updates here, so atm i'ved added more functionality, but you guys can also always make suggestions for what i should do! even with my little C# expierence, i know people that can do alot more, so request away!
     
    Last edited: Mar 25, 2016
  4. aD0UBLEj

    aD0UBLEj Well-Known Member

    Messages:
    138
    Likes Received:
    17
    Local Time:
    12:37 AM
    Just testing if 2^maxInt is prime?

    If so, hate to tell you but it isn't.
     
  5. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    2^maxINT-1, 500 million didgets, good luck, also, it now tests mersanne primes going down from maxInt, there's more options on the TODO i have to add
     
  6. aD0UBLEj

    aD0UBLEj Well-Known Member

    Messages:
    138
    Likes Received:
    17
    Local Time:
    12:37 AM
    ah lol, that may be a prime then

    2^n is definitely not :)
     
  7. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    i know that, ;) if you want to help, it's always welcome
     
  8. aD0UBLEj

    aD0UBLEj Well-Known Member

    Messages:
    138
    Likes Received:
    17
    Local Time:
    12:37 AM
    maxInt is what value?
     
  9. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    2^31-1, it's prime
     
  10. aD0UBLEj

    aD0UBLEj Well-Known Member

    Messages:
    138
    Likes Received:
    17
    Local Time:
    12:37 AM
  11. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    that is correct, ;)
     
  12. aD0UBLEj

    aD0UBLEj Well-Known Member

    Messages:
    138
    Likes Received:
    17
    Local Time:
    12:37 AM
    2^74,207,281 − 1
    Current largest known prime is that, this is approximately 2^2140062866 times bigger than that, so it's going to take a long time to calculate.
     
  13. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    thank you captain obvious, it's 500 million didgets long supposedly, i have it so that you can stop and start the program and it'll continue at the last checked number, i thought of that ;)
     
  14. aD0UBLEj

    aD0UBLEj Well-Known Member

    Messages:
    138
    Likes Received:
    17
    Local Time:
    12:37 AM
    Using Lucas-Lehmer primality test?
     
  15. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    ? no, i'm using a brute force method, you can submit a pull request for me to look at on the github implementing this though, the code's all there
     
  16. aD0UBLEj

    aD0UBLEj Well-Known Member

    Messages:
    138
    Likes Received:
    17
    Local Time:
    12:37 AM
    [​IMG]

    The issue with brute force is that you have to test division by every single integer below root(2^maxInt-1) which since it is so large will take forever. Doing this method you calculate S_(2^maxInt-3) using the recursion relation in the image (a huge number) and try dividing it by 2^maxInt-1, I don't know the language you are implementing the program in so wouldn't know how to implement this properly.
     
  17. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    That doesn't help at all, btw, implement it in any language in full and i can translate it, i already only brute force using specifically prime numbers, so it's calculating a prime number, modulating the other number, then doing this again, and if the number that's modulating the larger number square is greater than the larger number, the larger number is prime (I tested this, this is true)
     
  18. aD0UBLEj

    aD0UBLEj Well-Known Member

    Messages:
    138
    Likes Received:
    17
    Local Time:
    12:37 AM
    rough python pseudocode


    s0 = 4
    p = 2**31-1 #prime we are checking Mp for
    mp = 2**p-1 #prime we are checking

    s = s0

    for i in range(1, p-2): #might need to be p-1 here can't decide if this will loop one too few times
    sNew = (s**2)-2
    s = sNew


    if 's/mp mod mp = 0':
    mp is prime
    else
    mp not prime


    I don't quite follow this
     
  19. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    7:37 PM
    Yhea, i'm sorry, basically i'm taking y, which is gaurenteed prime, and taking the large number (h) and doing h mod y, then i make y the next prime number, after this i check if y^2 >= h, if it is, h is prime
    will implement this later, i think i understand it now, ;) the sole problem of the program development is that to actually TEST the thing i need to sidestep debugging in VS and build outside as it throws an error, but otherwise, thanks
     
  20. aD0UBLEj

    aD0UBLEj Well-Known Member

    Messages:
    138
    Likes Received:
    17
    Local Time:
    12:37 AM
    so you would start y=2, find h mod 2 = 1 ?
    where is the next y from for the iteration? 3?
    The issue I see here is that you essentially have to find all primes up to root(2^maxInt-1) via this method which is essentially impossible as the only way to guarantee this is to brute force division for each possible candidate for these lower primes.

    Hence using the proven method I suggested which is the fastest known method for calculating if it is prime. (although you still have to do approx 2^maxInt computations to reach the S_k and test it's divisibility) and I don't know if it is possible to be sufficiently accurate to do this with the size of the numbers involved (required S_k is larger in digits than prime you are attempting to check and I don't know how well code will handle that)
     

Share This Page